001 /**
002 *
003 * Copyright 2004 Protique Ltd
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 *
017 **/
018
019 package org.activemq.broker;
020
021 import org.activemq.io.WireFormat;
022 import org.activemq.message.ActiveMQMessage;
023 import org.activemq.message.ActiveMQXid;
024 import org.activemq.message.ConnectionInfo;
025 import org.activemq.message.ConsumerInfo;
026 import org.activemq.message.DurableUnsubscribe;
027 import org.activemq.message.MessageAck;
028 import org.activemq.message.ProducerInfo;
029 import org.activemq.message.SessionInfo;
030 import org.activemq.security.SecurityAdapter;
031 import org.activemq.service.Service;
032 import org.activemq.store.PersistenceAdapter;
033 import org.activemq.transport.DiscoveryAgent;
034 import org.activemq.transport.NetworkConnector;
035 import org.activemq.transport.TransportServerChannel;
036
037 import javax.jms.InvalidClientIDException;
038 import javax.jms.JMSException;
039 import javax.jms.JMSSecurityException;
040 import javax.transaction.xa.XAException;
041 import java.util.List;
042
043 /**
044 * The ActiveMQ JMS Broker Container which contains a {@link Broker} and one or more
045 * {@ BrokerConnector} instances talking over some {@link org.activemq.transport.TransportChannel}
046 * <p/>
047 * <b>Note</b> that once a broker container has been stopped it should be discarded and a new service
048 * instance created again. Calling start() on a stopped broker will not usually work.
049 *
050 * @version $Revision: 1.1.1.1 $
051 */
052 public interface BrokerContainer extends Service {
053
054 /**
055 * registers a new Connection
056 *
057 * @param client
058 * @param info infomation about the client-side Connection
059 * @throws InvalidClientIDException if the ClientID of the Connection is a duplicate
060 */
061 public void registerConnection(BrokerClient client, ConnectionInfo info) throws JMSException;
062
063 /**
064 * un-registers a Connection
065 *
066 * @param client
067 * @param info infomation about the client-side Connection
068 * @throws JMSException
069 */
070 public void deregisterConnection(BrokerClient client, ConnectionInfo info) throws JMSException;
071
072 /**
073 * Registers a MessageConsumer
074 *
075 * @param client
076 * @param info
077 * @throws JMSException
078 * @throws JMSSecurityException if client authentication fails for the Destination the
079 * Consumer applies for
080 */
081 public void registerMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
082
083 /**
084 * De-register a MessageConsumer from the Broker
085 *
086 * @param client
087 * @param info
088 * @throws JMSException
089 */
090 public void deregisterMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
091
092 /**
093 * Registers a MessageProducer
094 *
095 * @param client
096 * @param info
097 * @throws JMSException
098 * @throws JMSSecurityException if client authentication fails for the Destination the
099 * Consumer applies for
100 */
101
102 public void registerMessageProducer(BrokerClient client, ProducerInfo info) throws JMSException;
103
104 /**
105 * De-register a MessageProducer from the Broker
106 *
107 * @param client
108 * @param info
109 * @throws JMSException
110 */
111 public void deregisterMessageProducer(BrokerClient client, ProducerInfo info) throws JMSException;
112
113 /**
114 * Register a client-side Session (used for Monitoring)
115 *
116 * @param client
117 * @param info
118 * @throws JMSException
119 */
120
121 public void registerSession(BrokerClient client, SessionInfo info) throws JMSException;
122
123 /**
124 * De-register a client-side Session from the Broker (used for monitoring)
125 *
126 * @param client
127 * @param info
128 * @throws JMSException
129 */
130 public void deregisterSession(BrokerClient client, SessionInfo info) throws JMSException;
131
132 /**
133 * Start a transaction from the Client session
134 *
135 * @param client
136 * @param transactionId
137 * @throws JMSException
138 */
139 public void startTransaction(BrokerClient client, String transactionId) throws JMSException;
140
141 /**
142 * Rollback a transacton
143 *
144 * @param client
145 * @param transactionId
146 * @throws JMSException
147 */
148 public void rollbackTransaction(BrokerClient client, String transactionId) throws JMSException;
149
150 /**
151 * Commit a transaction
152 *
153 * @param client
154 * @param transactionId
155 * @throws JMSException
156 */
157 public void commitTransaction(BrokerClient client, String transactionId) throws JMSException;
158
159 /**
160 * Send a non-transacted message to the Broker
161 *
162 * @param client
163 * @param message
164 * @throws JMSException
165 */
166
167 public void sendMessage(BrokerClient client, ActiveMQMessage message) throws JMSException;
168
169 /**
170 * Acknowledge reciept of a message
171 *
172 * @param client
173 * @param ack
174 * @throws JMSException
175 */
176 public void acknowledgeMessage(BrokerClient client, MessageAck ack) throws JMSException;
177
178 /**
179 * Command to delete a durable topic subscription
180 *
181 * @param client
182 * @param ds
183 * @throws JMSException
184 */
185
186 public void durableUnsubscribe(BrokerClient client, DurableUnsubscribe ds) throws JMSException;
187
188 /**
189 * Start an XA transaction.
190 *
191 * @param client
192 * @param xid
193 */
194 public void startTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
195
196 /**
197 * Gets the prepared XA transactions.
198 *
199 * @param client
200 * @return
201 */
202 public ActiveMQXid[] getPreparedTransactions(BrokerClient client) throws XAException;
203
204 /**
205 * Prepare an XA transaction.
206 *
207 * @param client
208 * @param xid
209 */
210 public int prepareTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
211
212 /**
213 * Rollback an XA transaction.
214 *
215 * @param client
216 * @param xid
217 */
218 public void rollbackTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
219
220 /**
221 * Commit an XA transaction.
222 *
223 * @param client
224 * @param xid
225 * @param onePhase
226 */
227 public void commitTransaction(BrokerClient client, ActiveMQXid xid, boolean onePhase) throws XAException;
228
229 /**
230 * Called when a new connector is added to this container
231 *
232 * @param connector
233 */
234 public void addConnector(BrokerConnector connector);
235
236 /**
237 * Called when a connector is removed to this container
238 *
239 * @param connector
240 */
241 public void removeConnector(BrokerConnector connector);
242
243
244 /**
245 * @return the Broker for the Container
246 */
247 public Broker getBroker();
248
249 /**
250 * Returns the transport connectors used to communicate with
251 * clients
252 */
253 public List getTransportConnectors();
254
255 public void setTransportConnectors(List transportConnectors);
256
257 /**
258 * Returns a list of {@link org.activemq.transport.NetworkConnector}
259 * instances used to communicate with the network of {@link Broker} instances
260 */
261 public List getNetworkConnectors();
262
263 public void setNetworkConnectors(List networkConnectors);
264
265
266 /**
267 * Returns the persistence adapter
268 */
269 public PersistenceAdapter getPersistenceAdapter();
270
271 public void setPersistenceAdapter(PersistenceAdapter persistenceAdapter);
272
273 /**
274 * Returns the discovery agent if one is available or null if discovery is not
275 * enabled
276 */
277 public DiscoveryAgent getDiscoveryAgent();
278
279 public void setDiscoveryAgent(DiscoveryAgent discoveryAgent);
280
281 /**
282 * Returns the security adapter used to authenticate and authorize access to JMS resources
283 */
284 public SecurityAdapter getSecurityAdapter();
285
286 /**
287 * Sets the security adapter used to authenticate and authorize access to JMS resources
288 */
289 public void setSecurityAdapter(SecurityAdapter securityAdapter);
290
291 /**
292 * Adds a new network connector for the given URI
293 */
294 NetworkConnector addNetworkConnector(String uri) throws JMSException;
295
296 /**
297 * Adds a new network connector
298 *
299 * @return the newly created network connector
300 */
301 NetworkConnector addNetworkConnector();
302
303 /**
304 * Adds a new network connector
305 */
306 void addNetworkConnector(NetworkConnector connector);
307
308 /**
309 * Removes the given network connector
310 */
311 void removeNetworkConnector(NetworkConnector connector);
312
313 /**
314 * Adds a new transport connector for the given bind address
315 */
316 void addConnector(String bindAddress) throws JMSException;
317
318 /**
319 * Adds a new transport connector for the given bind address and wire format
320 */
321 void addConnector(String bindAddress, WireFormat wireFormat) throws JMSException;
322
323 /**
324 * Adds a new transport connector for the given transportConnector
325 */
326 void addConnector(TransportServerChannel transportConnector);
327
328 /**
329 * register a remote clientID
330 * @param remoteClientID
331 */
332
333 void registerRemoteClientID(String remoteClientID);
334
335 /**
336 * deregister a remote clientID
337 * @param remoteClientID
338 */
339 void deregisterRemoteClientID(String remoteClientID);
340
341 }