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.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.DurableUnsubscribe; 027 import org.activemq.message.MessageAck; 028 import org.activemq.message.ProducerInfo; 029 import org.activemq.message.SessionInfo; 030 import org.activemq.service.Service; 031 import org.activemq.transport.TransportServerChannel; 032 033 import javax.jms.JMSException; 034 import javax.jms.JMSSecurityException; 035 import javax.transaction.xa.XAException; 036 037 /** 038 * The Broker is the client side interface to the JMS server 039 * 040 * @version $Revision: 1.1.1.1 $ 041 */ 042 public interface BrokerConnector extends Service { 043 044 /** 045 * @return infomation about the Broker 046 */ 047 public BrokerInfo getBrokerInfo(); 048 049 /** 050 * @return the transport channel this broker is using 051 */ 052 public TransportServerChannel getServerChannel(); 053 054 /** 055 * Get a hint about the broker capacity for more messages 056 * 057 * @return percentage value (0-100) about how much capacity the 058 * broker has 059 */ 060 public int getBrokerCapacity(); 061 062 /** 063 * Register a Broker Client 064 * 065 * @param client 066 * @param info contains infomation about the Connection this Client 067 * represents 068 * @throws JMSException 069 * @throws javax.jms.InvalidClientIDException 070 * if the JMS client specifies an invalid or duplicate client 071 * ID. 072 * @throws JMSSecurityException if client authentication fails due to an invalid user name or 073 * password. 074 */ 075 public void registerClient(BrokerClient client, ConnectionInfo info) throws JMSException; 076 077 /** 078 * Deregister a Broker Client 079 * 080 * @param client 081 * @param info 082 * @throws JMSException if some internal error occurs 083 */ 084 085 public void deregisterClient(BrokerClient client, ConnectionInfo info) throws JMSException; 086 087 /** 088 * Registers a MessageConsumer 089 * 090 * @param client 091 * @param info 092 * @throws JMSException 093 * @throws JMSSecurityException if client authentication fails for the Destination the 094 * Consumer applies for 095 */ 096 public void registerMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException; 097 098 /** 099 * De-register a MessageConsumer from the Broker 100 * 101 * @param client 102 * @param info 103 * @throws JMSException 104 */ 105 public void deregisterMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException; 106 107 /** 108 * Registers a MessageProducer 109 * 110 * @param client 111 * @param info 112 * @throws JMSException 113 * @throws JMSSecurityException if client authentication fails for the Destination the 114 * Consumer applies for 115 */ 116 117 public void registerMessageProducer(BrokerClient client, ProducerInfo info) throws JMSException; 118 119 /** 120 * De-register a MessageProducer from the Broker 121 * 122 * @param client 123 * @param info 124 * @throws JMSException 125 */ 126 public void deregisterMessageProducer(BrokerClient client, ProducerInfo info) throws JMSException; 127 128 /** 129 * Register a client-side Session (used for Monitoring) 130 * 131 * @param client 132 * @param info 133 * @throws JMSException 134 */ 135 136 public void registerSession(BrokerClient client, SessionInfo info) throws JMSException; 137 138 /** 139 * De-register a client-side Session from the Broker (used for monitoring) 140 * 141 * @param client 142 * @param info 143 * @throws JMSException 144 */ 145 public void deregisterSession(BrokerClient client, SessionInfo info) throws JMSException; 146 147 /** 148 * Start a transaction from the Client session 149 * 150 * @param client 151 * @param transactionId 152 * @throws JMSException 153 */ 154 public void startTransaction(BrokerClient client, String transactionId) throws JMSException; 155 156 /** 157 * Rollback a transacton 158 * 159 * @param client 160 * @param transactionId 161 * @throws JMSException 162 */ 163 public void rollbackTransaction(BrokerClient client, String transactionId) throws JMSException; 164 165 /** 166 * Commit a transaction 167 * 168 * @param client 169 * @param transactionId 170 * @throws JMSException 171 */ 172 public void commitTransaction(BrokerClient client, String transactionId) throws JMSException; 173 174 175 /** 176 * Start an XA transaction 177 * 178 * @param client 179 * @param xid 180 * @throws XAException 181 */ 182 public void startTransaction(BrokerClient client, ActiveMQXid xid) throws XAException; 183 184 /** 185 * Get all the Xids of the prepared XA transactions. 186 * 187 * @param client 188 * @return 189 * @throws XAException 190 */ 191 public ActiveMQXid[] getPreparedTransactions(BrokerClient client) throws XAException; 192 193 /** 194 * Prepare an XA transaction. 195 * 196 * @param client 197 * @param xid 198 * @return 199 * @throws XAException 200 */ 201 public int prepareTransaction(BrokerClient client, ActiveMQXid xid) throws XAException; 202 203 /** 204 * Rollback an XA transaction. 205 * 206 * @param client 207 * @param xid 208 * @throws XAException 209 */ 210 public void rollbackTransaction(BrokerClient client, ActiveMQXid xid) throws XAException; 211 212 /** 213 * Commit an XA transaction. 214 * 215 * @param client 216 * @param xid 217 * @param onePhase 218 * @throws XAException 219 */ 220 public void commitTransaction(BrokerClient client, ActiveMQXid xid, boolean onePhase) throws XAException; 221 222 /** 223 * Send a non-transacted message to the Broker 224 * 225 * @param client 226 * @param message 227 * @throws JMSException 228 */ 229 230 public void sendMessage(BrokerClient client, ActiveMQMessage message) throws JMSException; 231 232 /** 233 * Acknowledge reciept of a message 234 * 235 * @param client 236 * @param ack 237 * @throws JMSException 238 */ 239 public void acknowledgeMessage(BrokerClient client, MessageAck ack) throws JMSException; 240 241 /** 242 * Command to delete a durable topic subscription 243 * 244 * @param client 245 * @param ds 246 * @throws JMSException 247 */ 248 249 public void durableUnsubscribe(BrokerClient client, DurableUnsubscribe ds) throws JMSException; 250 251 /** 252 * Gets the unique id of the resource manager used for managing xa 253 * transactions. 254 * 255 * @param client 256 * @return the id 257 */ 258 public String getResourceManagerId(BrokerClient client); 259 260 /** 261 * @return the BrokerContainer for this Connector 262 */ 263 public BrokerContainer getBrokerContainer(); 264 265 266 }