001 /**
002 *
003 * Copyright 2004 Hiram Chirino
004 * Copyright 2004 Protique Ltd
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 *
018 **/
019 package org.activemq.store.cache;
020
021 import javax.jms.JMSException;
022
023 import org.activemq.message.ConsumerInfo;
024 import org.activemq.service.MessageIdentity;
025 import org.activemq.service.SubscriberEntry;
026 import org.activemq.store.RecoveryListener;
027 import org.activemq.store.TopicMessageStore;
028
029 /**
030 * A MessageStore that uses an in memory cache to speed up getMessage() method calls.
031 *
032 * @version $Revision: 1.1.1.1 $
033 */
034 public class CacheTopicMessageStore extends CacheMessageStore implements TopicMessageStore {
035
036 private final TopicMessageStore longTermStore;
037
038 public CacheTopicMessageStore(CachePersistenceAdapter adapter, TopicMessageStore longTermStore, MessageCache cache) {
039 super(adapter, longTermStore, cache);
040 this.longTermStore = longTermStore;
041 }
042
043 //
044 // The following methods just delegate to the longTermStore.
045 //
046 public void setLastAcknowledgedMessageIdentity(String subscription, MessageIdentity messageIdentity) throws JMSException {
047 longTermStore.setLastAcknowledgedMessageIdentity(subscription, messageIdentity);
048 }
049
050 public MessageIdentity getLastestMessageIdentity() throws JMSException {
051 return longTermStore.getLastestMessageIdentity();
052 }
053
054 public synchronized void recoverSubscription(String subscriptionId, MessageIdentity lastDispatchedMessage, RecoveryListener listener) throws JMSException {
055 longTermStore.recoverSubscription(subscriptionId, lastDispatchedMessage, listener);
056 }
057
058 public void setSubscriberEntry(ConsumerInfo info, SubscriberEntry subscriberEntry) throws JMSException {
059 longTermStore.setSubscriberEntry(info, subscriberEntry);
060 }
061
062 public SubscriberEntry getSubscriberEntry(ConsumerInfo info) throws JMSException {
063 return longTermStore.getSubscriberEntry(info);
064 }
065
066 public void incrementMessageCount(MessageIdentity messageId) throws JMSException {
067 longTermStore.incrementMessageCount(messageId);
068 }
069
070 public void decrementMessageCountAndMaybeDelete(MessageIdentity msgId) throws JMSException {
071 longTermStore.decrementMessageCountAndMaybeDelete(msgId);
072 }
073
074 public void deleteSubscription(String subcription) throws JMSException {
075 longTermStore.deleteSubscription(subcription);
076 }
077
078 }