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 package org.activemq.broker;
019
020 import org.activemq.capacity.CapacityMonitor;
021 import org.activemq.message.ActiveMQMessage;
022 import org.activemq.message.ActiveMQXid;
023 import org.activemq.message.BrokerInfo;
024 import org.activemq.message.ConnectionInfo;
025 import org.activemq.message.ConsumerInfo;
026 import org.activemq.message.MessageAck;
027 import org.activemq.message.ProducerInfo;
028 import org.activemq.security.SecurityAdapter;
029 import org.activemq.service.DeadLetterPolicy;
030 import org.activemq.service.MessageContainerManager;
031 import org.activemq.service.RedeliveryPolicy;
032 import org.activemq.service.Service;
033 import org.activemq.store.PersistenceAdapter;
034
035 import javax.jms.JMSException;
036 import javax.naming.Context;
037 import javax.transaction.xa.XAException;
038 import java.io.File;
039 import java.util.Hashtable;
040 import java.util.Map;
041
042 /**
043 * The Message Broker which routes messages,
044 * maintains subscriptions and connections, acknowlegdges messages and handles
045 * transactions.
046 *
047 * @version $Revision: 1.1.1.1 $
048 */
049 public interface Broker extends Service, CapacityMonitor {
050
051 /**
052 * Get's the admin interface of the broker.
053 *
054 * @return the admin interface of the broker.
055 */
056 public BrokerAdmin getBrokerAdmin();
057
058 public BrokerInfo getBrokerInfo();
059
060 /**
061 * Notification of a new client attempting to connect, which can
062 * be rejected if authentication or authorization fails.
063 */
064 public void addClient(BrokerClient client, ConnectionInfo info) throws JMSException;
065
066 /**
067 * A hint to the broker that an BrokerClient has stopped
068 * This enables the broker to clean-up any outstanding processing
069 * that may be outstanding
070 */
071 public void removeClient(BrokerClient client, ConnectionInfo info) throws JMSException;
072
073 /**
074 * Adds a new message producer, which could be rejected due to authorization
075 */
076 public void addMessageProducer(BrokerClient client, ProducerInfo info) throws JMSException;
077
078 /**
079 * Removes a producer
080 */
081 public void removeMessageProducer(BrokerClient client, ProducerInfo info) throws JMSException;
082
083
084 /**
085 * Add an active message consumer, which could be rejected due to authorization
086 */
087 public void addMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
088
089 /**
090 * remove an active message consumer
091 */
092 public void removeMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
093
094
095 /**
096 * send a message to the broker
097 */
098 public void sendMessage(BrokerClient client, ActiveMQMessage message) throws JMSException;
099
100 /**
101 * Acknowledge positively or negatively, the consumption of a message by the Message Consumer
102 */
103 public void acknowledgeMessage(BrokerClient client, MessageAck ack) throws JMSException;
104
105 /**
106 * gets a list of all the prepared xa transactions.
107 *
108 * @param client
109 */
110 public ActiveMQXid[] getPreparedTransactions(BrokerClient client) throws XAException;
111
112 /**
113 * Delete a durable subscriber
114 *
115 * @param clientId
116 * @param subscriberName
117 * @throws JMSException if the subscriber doesn't exist or is still active
118 */
119 public void deleteSubscription(String clientId, String subscriberName) throws JMSException;
120
121 /**
122 * start a transaction
123 *
124 * @param client
125 * @param transactionId
126 */
127 public void startTransaction(BrokerClient client, String transactionId) throws JMSException;
128
129 /**
130 * commit a transaction
131 *
132 * @param client
133 * @param transactionId
134 * @throws JMSException
135 */
136 public void commitTransaction(BrokerClient client, String transactionId) throws JMSException;
137
138 /**
139 * rollback a transaction
140 *
141 * @param client
142 * @param transactionId
143 * @throws JMSException
144 */
145 public void rollbackTransaction(BrokerClient client, String transactionId) throws JMSException;
146
147
148 /**
149 * @param client
150 * @param xid
151 * @throws XAException
152 */
153 public void startTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
154
155 /**
156 * @param client
157 * @param xid
158 * @return
159 * @throws XAException
160 */
161 public int prepareTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
162
163 /**
164 * @param client
165 * @param xid
166 * @throws XAException
167 */
168
169 public void rollbackTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
170
171 /**
172 * @param client
173 * @param xid
174 * @param onePhase
175 * @throws XAException
176 */
177 public void commitTransaction(BrokerClient client, ActiveMQXid xid, boolean onePhase) throws XAException;
178
179
180 // Properties
181 //-------------------------------------------------------------------------
182
183 /**
184 * Get a temp directory - used for spooling
185 *
186 * @return a File ptr to the directory
187 */
188 public File getTempDir();
189
190 /**
191 * @return the name of the Broker
192 */
193 public String getBrokerName();
194
195 /**
196 * @return the name of the cluster the broker belongs to
197 */
198 public String getBrokerClusterName();
199
200 /**
201 * @return the PersistenceAdaptor
202 */
203 public PersistenceAdapter getPersistenceAdapter();
204
205 /**
206 * set the persistence adaptor
207 *
208 * @param persistenceAdapter
209 */
210 public void setPersistenceAdapter(PersistenceAdapter persistenceAdapter);
211
212 /**
213 * @return a map, indexed by name of the container managers
214 */
215 public Map getContainerManagerMap();
216
217 /**
218 * Returns the naming context of the destinations available in this broker
219 *
220 * @param environment
221 * @return the context
222 */
223 public Context getDestinationContext(Hashtable environment);
224
225 /**
226 * Add a ConsumerInfoListener to the Broker
227 *
228 * @param l
229 */
230 public void addConsumerInfoListener(ConsumerInfoListener l);
231
232 /**
233 * Remove a ConsumerInfoListener from the Broker
234 *
235 * @param l
236 */
237 public void removeConsumerInfoListener(ConsumerInfoListener l);
238
239
240 /**
241 * @return the MessageContainerManager for durable topics
242 */
243 public MessageContainerManager getPersistentTopicContainerManager();
244
245 /**
246 * @return the MessageContainerManager for transient topics
247 */
248 public MessageContainerManager getTransientTopicContainerManager();
249
250 /**
251 * @return the MessageContainerManager for persistent queues
252 */
253 public MessageContainerManager getPersistentQueueContainerManager();
254
255 /**
256 * @return the MessageContainerManager for transient queues
257 */
258 public MessageContainerManager getTransientQueueContainerManager();
259
260 /**
261 * Returns the security adapter used to authenticate and authorize access to JMS resources
262 */
263 public SecurityAdapter getSecurityAdapter();
264
265 /**
266 * Sets the security adapter used to authenticate and authorize access to JMS resources
267 */
268 public void setSecurityAdapter(SecurityAdapter securityAdapter);
269
270 /**
271 * @return the RedeliveryPolicy
272 */
273 RedeliveryPolicy getRedeliveryPolicy();
274
275 /**
276 * set the redelivery policy
277 * @param redeliveryPolicy
278 */
279 void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy);
280
281 /**
282 * @return the DeadLetterPolicy
283 */
284 public DeadLetterPolicy getDeadLetterPolicy();
285
286 /**
287 * set the dead letter policy
288 * @param deadLetterPolicy
289 */
290 public void setDeadLetterPolicy(DeadLetterPolicy deadLetterPolicy);
291
292 /**
293 * Add a message to a dead letter queue
294 * @param deadLetterName
295 * @param message
296 * @throws JMSException
297 */
298 public void sendToDeadLetterQueue(String deadLetterName,ActiveMQMessage message) throws JMSException;
299
300 }