Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/activemq/store/cache/CacheTopicMessageStore.java


1   /**
2    * 
3    * Copyright 2004 Hiram Chirino
4    * Copyright 2004 Protique Ltd
5    * 
6    * Licensed under the Apache License, Version 2.0 (the "License"); 
7    * you may not use this file except in compliance with the License. 
8    * You may obtain a copy of the License at 
9    * 
10   * http://www.apache.org/licenses/LICENSE-2.0
11   * 
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS, 
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
15   * See the License for the specific language governing permissions and 
16   * limitations under the License. 
17   * 
18   **/
19  package org.activemq.store.cache;
20  
21  import javax.jms.JMSException;
22  
23  import org.activemq.message.ConsumerInfo;
24  import org.activemq.service.MessageIdentity;
25  import org.activemq.service.SubscriberEntry;
26  import org.activemq.store.RecoveryListener;
27  import org.activemq.store.TopicMessageStore;
28  
29  /**
30   * A MessageStore that uses an in memory cache to speed up getMessage() method calls.
31   *
32   * @version $Revision: 1.1.1.1 $
33   */
34  public class CacheTopicMessageStore extends CacheMessageStore implements TopicMessageStore {
35  
36      private final TopicMessageStore longTermStore;
37  
38      public CacheTopicMessageStore(CachePersistenceAdapter adapter, TopicMessageStore longTermStore, MessageCache cache) {
39          super(adapter, longTermStore, cache);
40          this.longTermStore = longTermStore;
41      }
42  
43      //
44      // The following methods just delegate to the longTermStore.
45      //
46      public void setLastAcknowledgedMessageIdentity(String subscription, MessageIdentity messageIdentity) throws JMSException {
47          longTermStore.setLastAcknowledgedMessageIdentity(subscription, messageIdentity);
48      }
49  
50      public MessageIdentity getLastestMessageIdentity() throws JMSException {
51          return longTermStore.getLastestMessageIdentity();
52      }
53  
54      public synchronized void recoverSubscription(String subscriptionId, MessageIdentity lastDispatchedMessage, RecoveryListener listener) throws JMSException {
55          longTermStore.recoverSubscription(subscriptionId, lastDispatchedMessage, listener);
56      }
57  
58      public void setSubscriberEntry(ConsumerInfo info, SubscriberEntry subscriberEntry) throws JMSException {
59          longTermStore.setSubscriberEntry(info, subscriberEntry);
60      }
61  
62      public SubscriberEntry getSubscriberEntry(ConsumerInfo info) throws JMSException {
63          return longTermStore.getSubscriberEntry(info);
64      }
65  
66      public void incrementMessageCount(MessageIdentity messageId) throws JMSException {
67          longTermStore.incrementMessageCount(messageId);
68      }
69  
70      public void decrementMessageCountAndMaybeDelete(MessageIdentity msgId) throws JMSException {
71          longTermStore.decrementMessageCountAndMaybeDelete(msgId);
72      }
73  
74      public void deleteSubscription(String subcription) throws JMSException {
75          longTermStore.deleteSubscription(subcription);
76      }
77  
78  }