Broker 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  package org.codehaus.activemq.broker;
    19
    20  import org.codehaus.activemq.capacity.CapacityMonitor;
    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.MessageAck;
    26  import org.codehaus.activemq.message.ProducerInfo;
    27  import org.codehaus.activemq.security.SecurityAdapter;
    28  import org.codehaus.activemq.service.MessageContainerManager;
    29  import org.codehaus.activemq.service.Service;
    30  import org.codehaus.activemq.service.RedeliveryPolicy;
    31  import org.codehaus.activemq.store.PersistenceAdapter;
    32
    33  import javax.jms.JMSException;
    34  import javax.naming.Context;
    35  import javax.transaction.xa.XAException;
    36  import java.io.File;
    37  import java.util.Hashtable;
    38  import java.util.Map;
    39
    40  /***
    41   * The Message Broker which routes messages,
    42   * maintains subscriptions and connections, acknowlegdges messages and handles
    43   * transactions.
    44   *
    45   * @version $Revision: 1.15 $
    46   */
    47  public interface Broker extends Service, CapacityMonitor {
    48
    49      /***
    50       * Notification of a new client attempting to connect, which can
    51       * be rejected if authentication or authorization fails.
    52       */
    53      public void addClient(BrokerClient client, ConnectionInfo info) throws JMSException;
    54
    55      /***
    56       * A hint to the broker that an BrokerClient has stopped
    57       * This enables the broker to clean-up any outstanding processing
    58       * that may be outstanding
    59       */
    60      public void removeClient(BrokerClient client, ConnectionInfo info) throws JMSException;
    61
    62      /***
    63       * Adds a new message producer, which could be rejected due to authorization
    64       */
    65      public void addMessageProducer(BrokerClient client, ProducerInfo info) throws JMSException;
    66
    67      /***
    68       * Removes a producer
    69       */
    70      public void removeMessageProducer(BrokerClient client, ProducerInfo info) throws JMSException;
    71
    72
    73      /***
    74       * Add an active message consumer, which could be rejected due to authorization
    75       */
    76      public void addMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
    77
    78      /***
    79       * remove an active message consumer
    80       */
    81      public void removeMessageConsumer(BrokerClient client, ConsumerInfo info) throws JMSException;
    82
    83
    84      /***
    85       * send a message to the broker
    86       */
    87      public void sendMessage(BrokerClient client, ActiveMQMessage message) throws JMSException;
    88
    89      /***
    90       * send a message to the broker within a transaction
    91       */
    92      public void sendTransactedMessage(BrokerClient client, String transactionId, ActiveMQMessage message) throws JMSException;
    93
    94      /***
    95       * Acknowledge positively or negatively, the consumption of a message by the Message Consumer
    96       */
    97      public void acknowledgeMessage(BrokerClient client, MessageAck ack) throws JMSException;
    98
    99      /***
    100      * Acknowledge positively or negatively, the consumption of a message within a transaction
    101      */
    102     public void acknowledgeTransactedMessage(BrokerClient client, String transactionId, MessageAck ack) throws JMSException;
    103
    104     /***
    105      * gets a list of all the prepared xa transactions.
    106      *
    107      * @param client
    108      */
    109     public ActiveMQXid[] getPreparedTransactions(BrokerClient client) throws XAException;
    110
    111
    112     /***
    113      * Called after a rollback of a JMS transaction to redeliver the message to the consumers
    114      * dispatch queue
    115      *
    116      * @param client
    117      * @param ack
    118      */
    119     public void redeliverMessage(BrokerClient client, MessageAck ack) throws JMSException;
    120
    121     /***
    122      * Delete a durable subscriber
    123      *
    124      * @param clientId
    125      * @param subscriberName
    126      * @throws JMSException if the subscriber doesn't exist or is still active
    127      */
    128     public void deleteSubscription(String clientId, String subscriberName) throws JMSException;
    129
    130     /***
    131      * start a transaction
    132      *
    133      * @param client
    134      * @param transactionId
    135      */
    136     public void startTransaction(BrokerClient client, String transactionId) throws JMSException;
    137
    138     /***
    139      * commit a transaction
    140      *
    141      * @param client
    142      * @param transactionId
    143      * @throws JMSException
    144      */
    145     public void commitTransaction(BrokerClient client, String transactionId) throws JMSException;
    146
    147     /***
    148      * rollback a transaction
    149      *
    150      * @param client
    151      * @param transactionId
    152      * @throws JMSException
    153      */
    154     public void rollbackTransaction(BrokerClient client, String transactionId) throws JMSException;
    155
    156
    157     /***
    158      * @param client
    159      * @param xid
    160      * @throws XAException
    161      */
    162     public void startTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
    163
    164     /***
    165      * @param client
    166      * @param xid
    167      * @return
    168      * @throws XAException
    169      */
    170     public int prepareTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
    171
    172     /***
    173      * @param client
    174      * @param xid
    175      * @throws XAException
    176      */
    177
    178     public void rollbackTransaction(BrokerClient client, ActiveMQXid xid) throws XAException;
    179
    180     /***
    181      * @param client
    182      * @param xid
    183      * @param onePhase
    184      * @throws XAException
    185      */
    186     public void commitTransaction(BrokerClient client, ActiveMQXid xid, boolean onePhase) throws XAException;
    187
    188
    189     // Properties
    190     //-------------------------------------------------------------------------
    191
    192     /***
    193      * Get a temp directory - used for spooling
    194      *
    195      * @return a File ptr to the directory
    196      */
    197     public File getTempDir();
    198
    199     /***
    200      * @return the name of the Broker
    201      */
    202     public String getBrokerName();
    203
    204     /***
    205      * @return the name of the cluster the broker belongs to
    206      */
    207     public String getBrokerClusterName();
    208
    209     /***
    210      * @return the PersistenceAdaptor
    211      */
    212     public PersistenceAdapter getPersistenceAdapter();
    213
    214     /***
    215      * set the persistence adaptor
    216      *
    217      * @param persistenceAdapter
    218      */
    219     public void setPersistenceAdapter(PersistenceAdapter persistenceAdapter);
    220
    221     /***
    222      * @return a map, indexed by name of the container managers
    223      */
    224     public Map getContainerManagerMap();
    225
    226     /***
    227      * Returns the naming context of the destinations available in this broker
    228      *
    229      * @param environment
    230      * @return the context
    231      */
    232     public Context getDestinationContext(Hashtable environment);
    233
    234     /***
    235      * Add a ConsumerInfoListener to the Broker
    236      *
    237      * @param l
    238      */
    239     public void addConsumerInfoListener(ConsumerInfoListener l);
    240
    241     /***
    242      * Remove a ConsumerInfoListener from the Broker
    243      *
    244      * @param l
    245      */
    246     public void removeConsumerInfoListener(ConsumerInfoListener l);
    247
    248
    249     /***
    250      * @return the MessageContainerManager for durable topics
    251      */
    252     public MessageContainerManager getPersistentTopicContainerManager();
    253
    254     /***
    255      * @return the MessageContainerManager for transient topics
    256      */
    257     public MessageContainerManager getTransientTopicContainerManager();
    258
    259     /***
    260      * @return the MessageContainerManager for persistent queues
    261      */
    262     public MessageContainerManager getPersistentQueueContainerManager();
    263
    264     /***
    265      * @return the MessageContainerManager for transient queues
    266      */
    267     public MessageContainerManager getTransientQueueContainerManager();
    268
    269     /***
    270      * Returns the security adapter used to authenticate and authorize access to JMS resources
    271      */
    272     public SecurityAdapter getSecurityAdapter();
    273
    274     /***
    275      * Sets the security adapter used to authenticate and authorize access to JMS resources
    276      */
    277     public void setSecurityAdapter(SecurityAdapter securityAdapter);
    278
    279     RedeliveryPolicy getRedeliveryPolicy();
    280
    281     void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy);
    282 }