1
2
3
4
5
6
7 package org.codehaus.activemq.service;
8
9 import org.codehaus.activemq.broker.BrokerClient;
10 import org.codehaus.activemq.message.ActiveMQMessage;
11 import org.codehaus.activemq.message.ConsumerInfo;
12 import org.codehaus.activemq.message.MessageAck;
13
14 import javax.jms.JMSException;
15
16 /***
17 * A manager of MessageContainer instances
18 */
19 public interface MessageContainerManager extends Service {
20 /***
21 * @param client
22 * @param info
23 * @throws JMSException
24 */
25 public abstract void addMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
26
27 /***
28 * @param client
29 * @param info
30 * @throws JMSException
31 */
32 public abstract void removeMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
33
34 /***
35 * Delete a durable subscriber
36 *
37 * @param clientId
38 * @param subscriberName
39 * @throws JMSException if the subscriber doesn't exist or is still active
40 */
41 public abstract void deleteSubscription(String clientId, String subscriberName) throws JMSException;
42
43 /***
44 * @param client
45 * @param message
46 * @throws JMSException
47 */
48 public abstract void sendMessage(BrokerClient client, ActiveMQMessage message) throws JMSException;
49
50 /***
51 * Acknowledge a message as being read and consumed by the Consumer
52 *
53 * @param client
54 * @param ack
55 * @throws JMSException
56 */
57 public abstract void acknowledgeMessage(BrokerClient client, MessageAck ack) throws JMSException;
58
59
60 /***
61 * Called after a rollback of a JMS transaction to redeliver the message to the consumers
62 * dispatch queue
63 *
64 * @param client
65 * @param ack
66 */
67 public void redeliverMessage(BrokerClient client, MessageAck ack) throws JMSException;
68
69 /***
70 * Poll for messages
71 *
72 * @throws JMSException
73 */
74 public abstract void poll() throws JMSException;
75
76
77 /***
78 * A hook when the transaction is about to be commited; so apply all outstanding commands to the
79 * Journal if using a Journal (transaction log)
80 *
81 * @param client
82 * @param transactionId
83 */
84 public void commitTransaction(BrokerClient client, String transactionId) throws JMSException;
85
86 /***
87 * A hook when the transaction is about to be rolled back; so discard all outstanding commands
88 * that are pending to be written to the Journal
89 *
90 * @param client
91 * @param transactionId
92 */
93 public void rollbackTransaction(BrokerClient client, String transactionId);
94
95 /***
96 * Allows the lookup of a specific named message container
97 *
98 * @param physicalName
99 * @return
100 */
101 public MessageContainer getContainer(String physicalName) throws JMSException;
102
103 /***
104 * This is a hook to notify the dispatcher for the clients subscription that
105 * we have acknowledged a message within a transaction but before the commit - so
106 * the message is not really being acknowledged here but this method is intended to be a hook
107 * to let the dispatcher know that we can now send another message to the client.
108 * <p/>
109 * Without this hook, if we have a prefetch value of 1, we can never consume 2 messages
110 * in a transaction, since the ack for the first message never arrives until the commit()
111 */
112 public void acknowledgeTransactedMessage(BrokerClient client, String transactionId, MessageAck ack) throws JMSException;
113 }