BrokerContainer xref

View Javadoc

    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.message.WireFormat;
    30  import org.codehaus.activemq.security.SecurityAdapter;
    31  import org.codehaus.activemq.service.Service;
    32  import org.codehaus.activemq.store.PersistenceAdapter;
    33  import org.codehaus.activemq.transport.DiscoveryAgent;
    34  import org.codehaus.activemq.transport.NetworkConnector;
    35  import org.codehaus.activemq.transport.TransportServerChannel;
    36
    37  import javax.jms.InvalidClientIDException;
    38  import javax.jms.JMSException;
    39  import javax.jms.JMSSecurityException;
    40  import javax.transaction.xa.XAException;
    41  import java.util.List;
    42
    43  /***
    44   * The ActiveMQ JMS Broker Container which contains a {@link Broker} and one or more
    45   * {@ BrokerConnector} instances talking over some {@link org.codehaus.activemq.transport.TransportChannel}
    46   * <p/>
    47   * <b>Note</b> that  once a broker container has been stopped it should be discarded and a new service
    48   * instance created again. Calling start() on a stopped broker will not usually work.
    49   *
    50   * @version $Revision: 1.9 $
    51   */
    52  public interface BrokerContainer extends Service {
    53
    54      /***
    55       * registers a new Connection
    56       *
    57       * @param client
    58       * @param info   infomation about the client-side Connection
    59       * @throws InvalidClientIDException if the ClientID of the Connection is a duplicate
    60       */
    61      public void registerConnection(BrokerClient client, ConnectionInfo info) throws JMSException;
    62
    63      /***
    64       * un-registers a Connection
    65       *
    66       * @param client
    67       * @param info   infomation about the client-side Connection
    68       * @throws JMSException
    69       */
    70      public void deregisterConnection(BrokerClient client, ConnectionInfo info) throws JMSException;
    71
    72      /***
    73       * Registers a MessageConsumer
    74       *
    75       * @param client
    76       * @param info
    77       * @throws JMSException
    78       * @throws JMSSecurityException if client authentication fails for the Destination the
    79       *                              Consumer applies for
    80       */
    81      public void registerMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
    82
    83      /***
    84       * De-register a MessageConsumer from the Broker
    85       *
    86       * @param client
    87       * @param info
    88       * @throws JMSException
    89       */
    90      public void deregisterMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
    91
    92      /***
    93       * Registers a MessageProducer
    94       *
    95       * @param client
    96       * @param info
    97       * @throws JMSException
    98       * @throws JMSSecurityException if client authentication fails for the Destination the
    99       *                              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 message with a transaction context
    161      *
    162      * @param client
    163      * @param transactionId
    164      * @param message
    165      * @throws JMSException
    166      */
    167     public void sendTransactedMessage(BrokerClient client, String transactionId, ActiveMQMessage message)
    168             throws JMSException;
    169
    170     /***
    171      * Acknowledge receipt of a message within a transaction context
    172      *
    173      * @param client
    174      * @param transactionId
    175      * @param ack
    176      * @throws JMSException
    177      */
    178     public void acknowledgeTransactedMessage(BrokerClient client, String transactionId, MessageAck ack)
    179             throws JMSException;
    180
    181     /***
    182      * Send a non-transacted message to the Broker
    183      *
    184      * @param client
    185      * @param message
    186      * @throws JMSException
    187      */
    188
    189     public void sendMessage(BrokerClient client, ActiveMQMessage message) throws JMSException;
    190
    191     /***
    192      * Acknowledge reciept of a message
    193      *
    194      * @param client
    195      * @param ack
    196      * @throws JMSException
    197      */
    198     public void acknowledgeMessage(BrokerClient client, MessageAck ack) throws JMSException;
    199
    200     /***
    201      * Command to delete a durable topic subscription
    202      *
    203      * @param client
    204      * @param ds
    205      * @throws JMSException
    206      */
    207
    208     public void durableUnsubscribe(BrokerClient client, DurableUnsubscribe ds) throws JMSException;
    209
    210     /***
    211      * Start an XA transaction.
    212      *
    213      * @param client
    214      * @param xid
    215      */
    216     public void startTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
    217
    218     /***
    219      * Gets the prepared XA transactions.
    220      *
    221      * @param client
    222      * @return
    223      */
    224     public ActiveMQXid[] getPreparedTransactions(BrokerClient client) throws XAException;
    225
    226     /***
    227      * Prepare an XA transaction.
    228      *
    229      * @param client
    230      * @param xid
    231      */
    232     public int prepareTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
    233
    234     /***
    235      * Rollback an XA transaction.
    236      *
    237      * @param client
    238      * @param xid
    239      */
    240     public void rollbackTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
    241
    242     /***
    243      * Commit an XA transaction.
    244      *
    245      * @param client
    246      * @param xid
    247      * @param onePhase
    248      */
    249     public void commitTransaction(BrokerClient client, ActiveMQXid xid, boolean onePhase) throws XAException;
    250
    251     /***
    252      * Called when a new connector is added to this container
    253      *
    254      * @param connector
    255      */
    256     public void addConnector(BrokerConnector connector);
    257
    258     /***
    259      * Called when a connector is removed to this container
    260      *
    261      * @param connector
    262      */
    263     public void removeConnector(BrokerConnector connector);
    264
    265
    266     /***
    267      * @return the Broker for the Container
    268      */
    269     public Broker getBroker();
    270
    271     /***
    272      * Returns the transport connectors used to communicate with
    273      * clients
    274      */
    275     public List getTransportConnectors();
    276
    277     public void setTransportConnectors(List transportConnectors);
    278
    279     /***
    280      * Returns a list of {@link org.codehaus.activemq.transport.NetworkConnector}
    281      * instances used to communicate with the network of {@link Broker} instances
    282      */
    283     public List getNetworkConnectors();
    284
    285     public void setNetworkConnectors(List networkConnectors);
    286
    287
    288     /***
    289      * Returns the persistence adapter
    290      */
    291     public PersistenceAdapter getPersistenceAdapter();
    292
    293     public void setPersistenceAdapter(PersistenceAdapter persistenceAdapter);
    294
    295     /***
    296      * Returns the discovery agent if one is available or null if discovery is not
    297      * enabled
    298      */
    299     public DiscoveryAgent getDiscoveryAgent();
    300
    301     public void setDiscoveryAgent(DiscoveryAgent discoveryAgent);
    302
    303     /***
    304      * Returns the security adapter used to authenticate and authorize access to JMS resources
    305      */
    306     public SecurityAdapter getSecurityAdapter();
    307
    308     /***
    309      * Sets the security adapter used to authenticate and authorize access to JMS resources
    310      */
    311     public void setSecurityAdapter(SecurityAdapter securityAdapter);
    312
    313     /***
    314      * Adds a new network connector for the given URI
    315      */
    316     NetworkConnector addNetworkConnector(String uri);
    317
    318     /***
    319      * Adds a new network connector
    320      *
    321      * @return the newly created network connector
    322      */
    323     NetworkConnector addNetworkConnector();
    324
    325     /***
    326      * Adds a new network connector
    327      */
    328     void addNetworkConnector(NetworkConnector connector);
    329
    330     /***
    331      * Removes the given network connector
    332      */
    333     void removeNetworkConnector(NetworkConnector connector);
    334
    335     /***
    336      * Adds a new transport connector for the given bind address
    337      */
    338     void addConnector(String bindAddress) throws JMSException;
    339
    340     /***
    341      * Adds a new transport connector for the given bind address and wire format
    342      */
    343     void addConnector(String bindAddress, WireFormat wireFormat) throws JMSException;
    344
    345     /***
    346      * Adds a new transport connector for the given transportConnector
    347      */
    348     void addConnector(TransportServerChannel transportConnector);
    349 }