1 /***
2 *
3 * Copyright 2004 Protique Ltd
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 **/
18
19 package org.codehaus.activemq.broker;
20
21 import org.codehaus.activemq.message.ActiveMQMessage;
22 import org.codehaus.activemq.message.ActiveMQXid;
23 import org.codehaus.activemq.message.ConnectionInfo;
24 import org.codehaus.activemq.message.ConsumerInfo;
25 import org.codehaus.activemq.message.DurableUnsubscribe;
26 import org.codehaus.activemq.message.MessageAck;
27 import org.codehaus.activemq.message.ProducerInfo;
28 import org.codehaus.activemq.message.SessionInfo;
29 import org.codehaus.activemq.service.Service;
30
31 import javax.jms.InvalidClientIDException;
32 import javax.jms.JMSException;
33 import javax.jms.JMSSecurityException;
34 import javax.transaction.xa.XAException;
35 import java.util.List;
36
37 /***
38 * The ActiveMQ JMS Broker Container which contains a {@link Broker} and one or more
39 * {@ BrokerConnector} instances talking over some {@link org.codehaus.activemq.transport.TransportChannel}
40 *
41 * @version $Revision: 1.4 $
42 */
43 public interface BrokerContainer extends Service {
44
45 /***
46 * registers a new Connection
47 *
48 * @param client
49 * @param info infomation about the client-side Connection
50 * @throws InvalidClientIDException if the ClientID of the Connection is a duplicate
51 */
52 public void registerConnection(BrokerClient client, ConnectionInfo info) throws InvalidClientIDException;
53
54 /***
55 * un-registers a Connection
56 *
57 * @param client
58 * @param info infomation about the client-side Connection
59 * @throws JMSException
60 */
61 public void deregisterConnection(BrokerClient client, ConnectionInfo info) throws JMSException;
62
63 /***
64 * Registers a MessageConsumer
65 *
66 * @param client
67 * @param info
68 * @throws JMSException
69 * @throws JMSSecurityException if client authentication fails for the Destination the
70 * Consumer applies for
71 */
72 public void registerMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
73
74 /***
75 * De-register a MessageConsumer from the Broker
76 *
77 * @param client
78 * @param info
79 * @throws JMSException
80 */
81 public void deregisterMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
82
83 /***
84 * Registers a MessageProducer
85 *
86 * @param client
87 * @param info
88 * @throws JMSException
89 * @throws JMSSecurityException if client authentication fails for the Destination the
90 * Consumer applies for
91 */
92
93 public void registerMessageProducer(BrokerClient client, ProducerInfo info) throws JMSException;
94
95 /***
96 * De-register a MessageProducer from the Broker
97 *
98 * @param client
99 * @param info
100 * @throws JMSException
101 */
102 public void deregisterMessageProducer(BrokerClient client, ProducerInfo info) throws JMSException;
103
104 /***
105 * Register a client-side Session (used for Monitoring)
106 *
107 * @param client
108 * @param info
109 * @throws JMSException
110 */
111
112 public void registerSession(BrokerClient client, SessionInfo info) throws JMSException;
113
114 /***
115 * De-register a client-side Session from the Broker (used for monitoring)
116 *
117 * @param client
118 * @param info
119 * @throws JMSException
120 */
121 public void deregisterSession(BrokerClient client, SessionInfo info) throws JMSException;
122
123 /***
124 * Start a transaction from the Client session
125 *
126 * @param client
127 * @param transactionId
128 * @throws JMSException
129 */
130 public void startTransaction(BrokerClient client, String transactionId) throws JMSException;
131
132 /***
133 * Rollback a transacton
134 *
135 * @param client
136 * @param transactionId
137 * @throws JMSException
138 */
139 public void rollbackTransaction(BrokerClient client, String transactionId) throws JMSException;
140
141 /***
142 * Commit a transaction
143 *
144 * @param client
145 * @param transactionId
146 * @throws JMSException
147 */
148 public void commitTransaction(BrokerClient client, String transactionId) throws JMSException;
149
150 /***
151 * send message with a transaction context
152 *
153 * @param client
154 * @param transactionId
155 * @param message
156 * @throws JMSException
157 */
158 public void sendTransactedMessage(BrokerClient client, String transactionId, ActiveMQMessage message)
159 throws JMSException;
160
161 /***
162 * Acknowledge receipt of a message within a transaction context
163 *
164 * @param client
165 * @param transactionId
166 * @param ack
167 * @throws JMSException
168 */
169 public void acknowledgeTransactedMessage(BrokerClient client, String transactionId, MessageAck ack)
170 throws JMSException;
171
172 /***
173 * Send a non-transacted message to the Broker
174 *
175 * @param client
176 * @param message
177 * @throws JMSException
178 */
179
180 public void sendMessage(BrokerClient client, ActiveMQMessage message) throws JMSException;
181
182 /***
183 * Acknowledge reciept of a message
184 *
185 * @param client
186 * @param ack
187 * @throws JMSException
188 */
189 public void acknowledgeMessage(BrokerClient client, MessageAck ack) throws JMSException;
190
191 /***
192 * Command to delete a durable topic subscription
193 *
194 * @param client
195 * @param ds
196 * @throws JMSException
197 */
198
199 public void durableUnsubscribe(BrokerClient client, DurableUnsubscribe ds) throws JMSException;
200
201 /***
202 * Start an XA transaction.
203 *
204 * @param client
205 * @param xid
206 */
207 public void startTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
208
209 /***
210 * Gets the prepared XA transactions.
211 *
212 * @param client
213 * @return
214 */
215 public ActiveMQXid[] getPreparedTransactions(BrokerClient client) throws XAException;
216
217 /***
218 * Prepare an XA transaction.
219 *
220 * @param client
221 * @param xid
222 */
223 public int prepareTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
224
225 /***
226 * Rollback an XA transaction.
227 *
228 * @param client
229 * @param xid
230 */
231 public void rollbackTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
232
233 /***
234 * Commit an XA transaction.
235 *
236 * @param client
237 * @param xid
238 * @param onePhase
239 */
240 public void commitTransaction(BrokerClient client, ActiveMQXid xid, boolean onePhase) throws XAException;
241
242 /***
243 * Called when a new connector is added to this container
244 *
245 * @param connector
246 */
247 public void addConnector(BrokerConnector connector);
248
249 /***
250 * Called when a connector is removed to this container
251 *
252 * @param connector
253 */
254 public void removeConnector(BrokerConnector connector);
255
256
257 /***
258 * @return the Broker for the Container
259 */
260 public Broker getBroker();
261
262 List getConnectors();
263 }