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.codehaus.activemq.store.cache;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23 import org.codehaus.activemq.message.ConsumerInfo;
24 import org.codehaus.activemq.message.MessageAck;
25 import org.codehaus.activemq.service.MessageContainer;
26 import org.codehaus.activemq.service.MessageIdentity;
27 import org.codehaus.activemq.service.SubscriberEntry;
28 import org.codehaus.activemq.service.Subscription;
29 import org.codehaus.activemq.store.TopicMessageStore;
30
31 import javax.jms.JMSException;
32
33 /***
34 * A MessageStore that uses an in memory cache to speed up getMessage() method calls.
35 *
36 * @version $Revision: 1.2 $
37 */
38 public class CacheTopicMessageStore extends CacheMessageStore implements TopicMessageStore {
39
40 private static final Log log = LogFactory.getLog(CacheTopicMessageStore.class);
41 private final TopicMessageStore longTermStore;
42
43 public CacheTopicMessageStore(CachePersistenceAdapter adapter, TopicMessageStore longTermStore, MessageCache cache) {
44 super(adapter, longTermStore, cache);
45 this.longTermStore = longTermStore;
46 }
47
48
49
50
51 public void setLastAcknowledgedMessageIdentity(Subscription subscription, MessageIdentity messageIdentity) throws JMSException {
52 longTermStore.setLastAcknowledgedMessageIdentity(subscription, messageIdentity);
53 }
54
55 public MessageIdentity getLastestMessageIdentity() throws JMSException {
56 return longTermStore.getLastestMessageIdentity();
57 }
58
59 public void recoverSubscription(final Subscription subscription, MessageIdentity lastDispatchedMessage) throws JMSException {
60 longTermStore.recoverSubscription(subscription, lastDispatchedMessage);
61 }
62
63 public void setSubscriberEntry(ConsumerInfo info, SubscriberEntry subscriberEntry) throws JMSException {
64 longTermStore.setSubscriberEntry(info, subscriberEntry);
65 }
66
67 public SubscriberEntry getSubscriberEntry(ConsumerInfo info) throws JMSException {
68 return longTermStore.getSubscriberEntry(info);
69 }
70
71 public void setMessageContainer(MessageContainer container) {
72 longTermStore.setMessageContainer(container);
73 }
74
75 public void incrementMessageCount(MessageIdentity messageId) throws JMSException {
76 longTermStore.incrementMessageCount(messageId);
77 }
78
79 public void decrementMessageCountAndMaybeDelete(MessageIdentity messageIdentity, MessageAck ack) throws JMSException {
80 longTermStore.decrementMessageCountAndMaybeDelete(messageIdentity, ack);
81 }
82
83 }