org.apache.james.jms.activemq
Class BrokerManager

java.lang.Object
  extended by org.apache.james.jms.activemq.BrokerManager

public class BrokerManager
extends java.lang.Object

Manages the connection to the local ActiveMQ broker.

Note: BrokerManager is intended to allow concurrent access. start() and stop are synchronized on the consumer register.


Constructor Summary
BrokerManager(org.apache.activemq.broker.BrokerService broker, org.apache.commons.logging.Log log)
           
 
Method Summary
 void consumeQueue(MailConsumer consumer, MailBuilder builder, java.lang.String destination)
          Sets the consumer as the listener for the queue with the given name.
 void start()
           
 void stop()
           
 void subscribeToTopic(MailConsumer consumer, MailBuilder builder, java.lang.String destination)
          Subscribes the consumer to the topic with the given name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BrokerManager

public BrokerManager(org.apache.activemq.broker.BrokerService broker,
                     org.apache.commons.logging.Log log)
Method Detail

start

public void start()
           throws javax.jms.JMSException
Throws:
javax.jms.JMSException

stop

public void stop()
          throws javax.jms.JMSException
Throws:
javax.jms.JMSException

consumeQueue

public void consumeQueue(MailConsumer consumer,
                         MailBuilder builder,
                         java.lang.String destination)
                  throws javax.jms.JMSException
Sets the consumer as the listener for the queue with the given name. If the broker has not been started, the consumer will be registered and added on start.

Parameters:
consumer - MailConsumer, not null
builder - MailBuilder, not null
destination - name of the destination queue, not null
Throws:
javax.jms.JMSException

subscribeToTopic

public void subscribeToTopic(MailConsumer consumer,
                             MailBuilder builder,
                             java.lang.String destination)
                      throws javax.jms.JMSException
Subscribes the consumer to the topic with the given name. If the broker has not been started, the consumer will be registered and subscribed on start.

Parameters:
consumer - MailConsumer, not null
builder - MailBuilder, not null
destination - name of the destination queue, not null
Throws:
javax.jms.JMSException


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.