org.activemq.broker.impl
Class DefaultBroker

java.lang.Object
  extended by org.activemq.capacity.DelegateCapacityMonitor
      extended by org.activemq.broker.impl.DefaultBroker
All Implemented Interfaces:
Broker, BrokerAdmin, CapacityMonitor, Service

public class DefaultBroker
extends DelegateCapacityMonitor
implements Broker, BrokerAdmin

The default Broker implementation

Version:
$Revision: 1.1.1.1 $

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.activemq.capacity.CapacityMonitor
CapacityMonitor.BasicCapacityMonitor
 
Field Summary
protected static Class[] NEWINSTANCE_PARAMETER_TYPES
           
protected static String PERSISTENCE_ADAPTER_FACTORY
           
protected static String PROPERTY_STORE_DIRECTORY
           
 
Constructor Summary
DefaultBroker(String brokerName)
           
DefaultBroker(String brokerName, MemoryBoundedObjectManager memoryManager)
           
DefaultBroker(String brokerName, PersistenceAdapter persistenceAdapter)
           
DefaultBroker(String brokerName, String cluserName)
           
DefaultBroker(String brokerName, String brokerClusterName, MemoryBoundedObjectManager memoryManager)
           
DefaultBroker(String brokerName, String brokerClusterName, PersistenceAdapter persistenceAdapter)
           
 
Method Summary
 void acknowledgeMessage(BrokerClient client, MessageAck ack)
          Acknowledge consumption of a message by the Message Consumer
 void addClient(BrokerClient client, ConnectionInfo info)
          Notification of a new client attempting to connect, which can be rejected if authentication or authorization fails.
 void addConsumerInfoListener(ConsumerInfoListener l)
          Add a ConsumerInfoListener to the Broker
 void addMessageConsumer(BrokerClient client, ConsumerInfo info)
          Add an active message consumer
 void addMessageProducer(BrokerClient client, ProducerInfo info)
          Adds a new message producer, which could be rejected due to authorization
protected  void checkValid()
           
 void commitTransaction(BrokerClient client, ActiveMQXid xid, boolean onePhase)
          Commit an XA Transaction.
 void commitTransaction(BrokerClient client, String transactionId)
          commit a transaction
protected  MessageContainerManager[] createContainerManagers()
          Factory method to create the default container managers
protected  JMSException createInstantiateAdapterException(String className, Throwable e)
           
 void createMessageContainer(ActiveMQDestination dest)
           
protected  PersistenceAdapter createPersistenceAdapter()
          Factory method to create a default persistence adapter
 void deleteSubscription(String clientId, String subscriberName)
          Delete a durable subscriber
 void destoryMessageContainer(ActiveMQDestination dest)
           
protected  void doMessageSend(BrokerClient client, ActiveMQMessage message)
           
protected  void fireConsumerInfo(BrokerClient client, ConsumerInfo info)
           
 BrokerAdmin getBrokerAdmin()
          Get's the admin interface of the broker.
 String getBrokerClusterName()
           
protected  BrokerContainerImpl getBrokerContainer()
           
 BrokerInfo getBrokerInfo()
           
 String getBrokerName()
           
 Map getContainerManagerMap()
           
 MessageContainerManager[] getContainerManagers()
           
 DeadLetterPolicy getDeadLetterPolicy()
           
 Context getDestinationContext(Hashtable environment)
          Returns the naming context of the destinations available in this broker
 long getMaximumMemoryUsage()
           
 MemoryBoundedObjectManager getMemoryManager()
           
 MessageContainerAdmin getMessageContainerAdmin(ActiveMQDestination dest)
           
 String getName()
          Get the name of the CapacityMonitor
 PersistenceAdapter getPersistenceAdapter()
           
 MessageContainerManager getPersistentQueueContainerManager()
           
 MessageContainerManager getPersistentTopicContainerManager()
           
 ActiveMQXid[] getPreparedTransactions(BrokerClient client)
          Gets the prepared XA transactions.
 TransactionStore getPreparedTransactionStore()
           
 MemoryBoundedQueueManager getQueueManager()
           
 RedeliveryPolicy getRedeliveryPolicy()
           
 SecurityAdapter getSecurityAdapter()
          Returns the security adapter used to authenticate and authorize access to JMS resources
protected  String getStoreDirectory()
           
 File getTempDir()
          Get a temp directory - used for spooling
 TransactionManager getTransactionManager()
           
 MessageContainerManager getTransientQueueContainerManager()
           
 MessageContainerManager getTransientTopicContainerManager()
           
 boolean isStarted()
           
 MessageContainerAdmin[] listMessageContainerAdmin()
           
protected  Class loadClass(String name, boolean ignoreErrors)
          Tries to load the given class from the current context class loader or class loader which loaded us or return null if the class could not be found
protected  void makeDefaultContainerManagers()
           
 int prepareTransaction(BrokerClient client, ActiveMQXid xid)
          Prepares an XA Transaciton.
 void removeClient(BrokerClient client, ConnectionInfo info)
          A hint to the broker that an BrokerClient has stopped This enables the broker to clean-up any outstanding processing that may be outstanding
 void removeConsumerInfoListener(ConsumerInfoListener l)
          Remove a ConsumerInfoListener from the Broker
 void removeMessageConsumer(BrokerClient client, ConsumerInfo info)
          remove an active message consumer
 void removeMessageProducer(BrokerClient client, ProducerInfo info)
          Removes a producer
 void rollbackTransaction(BrokerClient client, ActiveMQXid xid)
          Rollback an XA Transaction.
 void rollbackTransaction(BrokerClient client, String transactionId)
          rollback a transaction
 void sendMessage(BrokerClient client, ActiveMQMessage message)
          send a message to the broker
 void sendToDeadLetterQueue(String deadLetterName, ActiveMQMessage expiredMessage)
          Add a message to a dead letter queue
protected  void setBrokercontainer(BrokerContainerImpl container)
           
 void setContainerManagerMap(Map containerManagerMap)
           
 void setDeadLetterPolicy(DeadLetterPolicy deadLetterPolicy)
          set the dead letter policy
 void setMaximumMemoryUsage(long maximumMemoryUsage)
           
 void setPersistenceAdapter(PersistenceAdapter persistenceAdapter)
          set the persistence adaptor
 void setPreparedTransactionStore(TransactionStore preparedTransactionStore)
           
 void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
          set the redelivery policy
 void setSecurityAdapter(SecurityAdapter securityAdapter)
          Sets the security adapter used to authenticate and authorize access to JMS resources
 void setTempDir(File tempDir)
           
 void setTransactionManager(TransactionManager transactionManager)
           
 void start()
          Start this Service
 void startTransaction(BrokerClient client, ActiveMQXid xid)
          Starts an XA Transaction.
 void startTransaction(BrokerClient client, String transactionId)
          Start a transaction.
 void stop()
          stop this Service
 String toString()
           
protected  PersistenceAdapter tryCreatePersistenceAdapter(String className, File directory, boolean ignoreErrors)
           
protected  void validateConsumer(ConsumerInfo info)
          Ensures the consumer is valid, throwing a meaningful exception if not
 
Methods inherited from class org.activemq.capacity.DelegateCapacityMonitor
addCapacityEventListener, generateCapacityMonitorEvent, getCurrentCapacity, getCurrentValue, getRoundedCapacity, getRoundingFactor, getValueLimit, removeCapacityEventListener, setCurrentValue, setDelegate, setName, setRoundingFactor, setValueLimit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.activemq.capacity.CapacityMonitor
addCapacityEventListener, generateCapacityMonitorEvent, getCurrentCapacity, getCurrentValue, getRoundedCapacity, getRoundingFactor, getValueLimit, removeCapacityEventListener, setCurrentValue, setName, setRoundingFactor, setValueLimit
 

Field Detail

PROPERTY_STORE_DIRECTORY

protected static final String PROPERTY_STORE_DIRECTORY
See Also:
Constant Field Values

PERSISTENCE_ADAPTER_FACTORY

protected static final String PERSISTENCE_ADAPTER_FACTORY
See Also:
Constant Field Values

NEWINSTANCE_PARAMETER_TYPES

protected static final Class[] NEWINSTANCE_PARAMETER_TYPES
Constructor Detail

DefaultBroker

public DefaultBroker(String brokerName,
                     String brokerClusterName,
                     MemoryBoundedObjectManager memoryManager)

DefaultBroker

public DefaultBroker(String brokerName,
                     MemoryBoundedObjectManager memoryManager)

DefaultBroker

public DefaultBroker(String brokerName,
                     String cluserName)

DefaultBroker

public DefaultBroker(String brokerName)

DefaultBroker

public DefaultBroker(String brokerName,
                     String brokerClusterName,
                     PersistenceAdapter persistenceAdapter)

DefaultBroker

public DefaultBroker(String brokerName,
                     PersistenceAdapter persistenceAdapter)
Method Detail

isStarted

public boolean isStarted()

start

public void start()
           throws JMSException
Start this Service

Specified by:
start in interface Service
Throws:
JMSException

stop

public void stop()
          throws JMSException
stop this Service

Specified by:
stop in interface Service
Throws:
JMSException

addClient

public void addClient(BrokerClient client,
                      ConnectionInfo info)
               throws JMSException
Description copied from interface: Broker
Notification of a new client attempting to connect, which can be rejected if authentication or authorization fails.

Specified by:
addClient in interface Broker
Throws:
JMSException

removeClient

public void removeClient(BrokerClient client,
                         ConnectionInfo info)
                  throws JMSException
Description copied from interface: Broker
A hint to the broker that an BrokerClient has stopped This enables the broker to clean-up any outstanding processing that may be outstanding

Specified by:
removeClient in interface Broker
Throws:
JMSException

addMessageProducer

public void addMessageProducer(BrokerClient client,
                               ProducerInfo info)
                        throws JMSException
Description copied from interface: Broker
Adds a new message producer, which could be rejected due to authorization

Specified by:
addMessageProducer in interface Broker
Throws:
JMSException

removeMessageProducer

public void removeMessageProducer(BrokerClient client,
                                  ProducerInfo info)
                           throws JMSException
Description copied from interface: Broker
Removes a producer

Specified by:
removeMessageProducer in interface Broker
Throws:
JMSException

addMessageConsumer

public void addMessageConsumer(BrokerClient client,
                               ConsumerInfo info)
                        throws JMSException
Add an active message consumer

Specified by:
addMessageConsumer in interface Broker
Throws:
JMSException

removeMessageConsumer

public void removeMessageConsumer(BrokerClient client,
                                  ConsumerInfo info)
                           throws JMSException
remove an active message consumer

Specified by:
removeMessageConsumer in interface Broker
Throws:
JMSException

sendMessage

public void sendMessage(BrokerClient client,
                        ActiveMQMessage message)
                 throws JMSException
send a message to the broker

Specified by:
sendMessage in interface Broker
Throws:
JMSException

acknowledgeMessage

public void acknowledgeMessage(BrokerClient client,
                               MessageAck ack)
                        throws JMSException
Acknowledge consumption of a message by the Message Consumer

Specified by:
acknowledgeMessage in interface Broker
Throws:
JMSException

deleteSubscription

public void deleteSubscription(String clientId,
                               String subscriberName)
                        throws JMSException
Description copied from interface: Broker
Delete a durable subscriber

Specified by:
deleteSubscription in interface Broker
Throws:
JMSException - if the subscriber doesn't exist or is still active

startTransaction

public void startTransaction(BrokerClient client,
                             String transactionId)
                      throws JMSException
Start a transaction.

Specified by:
startTransaction in interface Broker
Throws:
JMSException
See Also:
Broker.startTransaction(org.activemq.broker.BrokerClient, java.lang.String)

commitTransaction

public void commitTransaction(BrokerClient client,
                              String transactionId)
                       throws JMSException
Description copied from interface: Broker
commit a transaction

Specified by:
commitTransaction in interface Broker
Throws:
JMSException

rollbackTransaction

public void rollbackTransaction(BrokerClient client,
                                String transactionId)
                         throws JMSException
rollback a transaction

Specified by:
rollbackTransaction in interface Broker
Throws:
JMSException

startTransaction

public void startTransaction(BrokerClient client,
                             ActiveMQXid xid)
                      throws XAException
Starts an XA Transaction.

Specified by:
startTransaction in interface Broker
Throws:
XAException
See Also:
Broker.startTransaction(org.activemq.broker.BrokerClient, org.activemq.message.ActiveMQXid)

prepareTransaction

public int prepareTransaction(BrokerClient client,
                              ActiveMQXid xid)
                       throws XAException
Prepares an XA Transaciton.

Specified by:
prepareTransaction in interface Broker
Returns:
Throws:
XAException
See Also:
Broker.prepareTransaction(org.activemq.broker.BrokerClient, org.activemq.message.ActiveMQXid)

rollbackTransaction

public void rollbackTransaction(BrokerClient client,
                                ActiveMQXid xid)
                         throws XAException
Rollback an XA Transaction.

Specified by:
rollbackTransaction in interface Broker
Throws:
XAException
See Also:
Broker.rollbackTransaction(org.activemq.broker.BrokerClient, org.activemq.message.ActiveMQXid)

commitTransaction

public void commitTransaction(BrokerClient client,
                              ActiveMQXid xid,
                              boolean onePhase)
                       throws XAException
Commit an XA Transaction.

Specified by:
commitTransaction in interface Broker
Throws:
XAException
See Also:
Broker.commitTransaction(org.activemq.broker.BrokerClient, org.activemq.message.ActiveMQXid, boolean)

getPreparedTransactions

public ActiveMQXid[] getPreparedTransactions(BrokerClient client)
                                      throws XAException
Gets the prepared XA transactions.

Specified by:
getPreparedTransactions in interface Broker
Throws:
XAException
See Also:
Broker.getPreparedTransactions(org.activemq.broker.BrokerClient)

getTempDir

public File getTempDir()
Get a temp directory - used for spooling

Specified by:
getTempDir in interface Broker
Returns:
a File ptr to the directory

getBrokerName

public String getBrokerName()
Specified by:
getBrokerName in interface Broker
Returns:
the name of the Broker

getBrokerClusterName

public String getBrokerClusterName()
Specified by:
getBrokerClusterName in interface Broker
Returns:
Returns the brokerClusterName.

setTempDir

public void setTempDir(File tempDir)

getContainerManagers

public MessageContainerManager[] getContainerManagers()

getContainerManagerMap

public Map getContainerManagerMap()
Specified by:
getContainerManagerMap in interface Broker
Returns:
a map, indexed by name of the container managers

setContainerManagerMap

public void setContainerManagerMap(Map containerManagerMap)

getPersistenceAdapter

public PersistenceAdapter getPersistenceAdapter()
Specified by:
getPersistenceAdapter in interface Broker
Returns:
the PersistenceAdaptor

setPersistenceAdapter

public void setPersistenceAdapter(PersistenceAdapter persistenceAdapter)
Description copied from interface: Broker
set the persistence adaptor

Specified by:
setPersistenceAdapter in interface Broker

getTransactionManager

public TransactionManager getTransactionManager()

setTransactionManager

public void setTransactionManager(TransactionManager transactionManager)

getSecurityAdapter

public SecurityAdapter getSecurityAdapter()
Description copied from interface: Broker
Returns the security adapter used to authenticate and authorize access to JMS resources

Specified by:
getSecurityAdapter in interface Broker

setSecurityAdapter

public void setSecurityAdapter(SecurityAdapter securityAdapter)
Description copied from interface: Broker
Sets the security adapter used to authenticate and authorize access to JMS resources

Specified by:
setSecurityAdapter in interface Broker

getRedeliveryPolicy

public RedeliveryPolicy getRedeliveryPolicy()
Specified by:
getRedeliveryPolicy in interface Broker
Returns:
the RedeliveryPolicy

setRedeliveryPolicy

public void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
Description copied from interface: Broker
set the redelivery policy

Specified by:
setRedeliveryPolicy in interface Broker

getPreparedTransactionStore

public TransactionStore getPreparedTransactionStore()

setPreparedTransactionStore

public void setPreparedTransactionStore(TransactionStore preparedTransactionStore)

getDeadLetterPolicy

public DeadLetterPolicy getDeadLetterPolicy()
Specified by:
getDeadLetterPolicy in interface Broker
Returns:
the DeadLetterPolicy

setDeadLetterPolicy

public void setDeadLetterPolicy(DeadLetterPolicy deadLetterPolicy)
set the dead letter policy

Specified by:
setDeadLetterPolicy in interface Broker
Parameters:
deadLetterPolicy -

getMaximumMemoryUsage

public long getMaximumMemoryUsage()
Returns:
Returns the maximumMemoryUsage.

setMaximumMemoryUsage

public void setMaximumMemoryUsage(long maximumMemoryUsage)
Parameters:
maximumMemoryUsage - The maximumMemoryUsage to set.

getDestinationContext

public Context getDestinationContext(Hashtable environment)
Description copied from interface: Broker
Returns the naming context of the destinations available in this broker

Specified by:
getDestinationContext in interface Broker
Returns:
the context

doMessageSend

protected void doMessageSend(BrokerClient client,
                             ActiveMQMessage message)
                      throws JMSException
Throws:
JMSException

createPersistenceAdapter

protected PersistenceAdapter createPersistenceAdapter()
                                               throws JMSException
Factory method to create a default persistence adapter

Returns:
Throws:
JMSException

tryCreatePersistenceAdapter

protected PersistenceAdapter tryCreatePersistenceAdapter(String className,
                                                         File directory,
                                                         boolean ignoreErrors)
                                                  throws JMSException
Throws:
JMSException

createInstantiateAdapterException

protected JMSException createInstantiateAdapterException(String className,
                                                         Throwable e)

loadClass

protected Class loadClass(String name,
                          boolean ignoreErrors)
                   throws JMSException
Tries to load the given class from the current context class loader or class loader which loaded us or return null if the class could not be found

Throws:
JMSException

getStoreDirectory

protected String getStoreDirectory()

createContainerManagers

protected MessageContainerManager[] createContainerManagers()
Factory method to create the default container managers

Returns:

makeDefaultContainerManagers

protected void makeDefaultContainerManagers()

validateConsumer

protected void validateConsumer(ConsumerInfo info)
                         throws JMSException
Ensures the consumer is valid, throwing a meaningful exception if not

Parameters:
info -
Throws:
JMSException

checkValid

protected void checkValid()
                   throws JMSException
Throws:
JMSException

addConsumerInfoListener

public void addConsumerInfoListener(ConsumerInfoListener l)
Add a ConsumerInfoListener to the Broker

Specified by:
addConsumerInfoListener in interface Broker
Parameters:
l -

removeConsumerInfoListener

public void removeConsumerInfoListener(ConsumerInfoListener l)
Remove a ConsumerInfoListener from the Broker

Specified by:
removeConsumerInfoListener in interface Broker
Parameters:
l -

fireConsumerInfo

protected void fireConsumerInfo(BrokerClient client,
                                ConsumerInfo info)

getPersistentTopicContainerManager

public MessageContainerManager getPersistentTopicContainerManager()
Specified by:
getPersistentTopicContainerManager in interface Broker
Returns:
the MessageContainerManager for durable topics

getTransientTopicContainerManager

public MessageContainerManager getTransientTopicContainerManager()
Specified by:
getTransientTopicContainerManager in interface Broker
Returns:
the MessageContainerManager for transient topics

getPersistentQueueContainerManager

public MessageContainerManager getPersistentQueueContainerManager()
Specified by:
getPersistentQueueContainerManager in interface Broker
Returns:
the MessageContainerManager for persistent queues

getTransientQueueContainerManager

public MessageContainerManager getTransientQueueContainerManager()
Specified by:
getTransientQueueContainerManager in interface Broker
Returns:
the MessageContainerManager for transient queues

getBrokerAdmin

public BrokerAdmin getBrokerAdmin()
Description copied from interface: Broker
Get's the admin interface of the broker.

Specified by:
getBrokerAdmin in interface Broker
Returns:
the admin interface of the broker.
See Also:
Broker.getBrokerAdmin()

createMessageContainer

public void createMessageContainer(ActiveMQDestination dest)
                            throws JMSException
Specified by:
createMessageContainer in interface BrokerAdmin
Throws:
JMSException

destoryMessageContainer

public void destoryMessageContainer(ActiveMQDestination dest)
                             throws JMSException
Specified by:
destoryMessageContainer in interface BrokerAdmin
Throws:
JMSException

getMessageContainerAdmin

public MessageContainerAdmin getMessageContainerAdmin(ActiveMQDestination dest)
                                               throws JMSException
Specified by:
getMessageContainerAdmin in interface BrokerAdmin
Throws:
JMSException

listMessageContainerAdmin

public MessageContainerAdmin[] listMessageContainerAdmin()
                                                  throws JMSException
Specified by:
listMessageContainerAdmin in interface BrokerAdmin
Throws:
JMSException
See Also:
org.activemq.broker.BrokerAdmin#listDestinations()

sendToDeadLetterQueue

public void sendToDeadLetterQueue(String deadLetterName,
                                  ActiveMQMessage expiredMessage)
                           throws JMSException
Add a message to a dead letter queue

Specified by:
sendToDeadLetterQueue in interface Broker
Parameters:
deadLetterName -
message -
Throws:
JMSException

getMemoryManager

public MemoryBoundedObjectManager getMemoryManager()
Returns:
Returns the memoryManager.

getQueueManager

public MemoryBoundedQueueManager getQueueManager()
Returns:
Returns the queueManager.

getName

public String getName()
Description copied from class: DelegateCapacityMonitor
Get the name of the CapacityMonitor

Specified by:
getName in interface CapacityMonitor
Overrides:
getName in class DelegateCapacityMonitor
Returns:
the name

toString

public String toString()
Overrides:
toString in class Object

getBrokerInfo

public BrokerInfo getBrokerInfo()
Specified by:
getBrokerInfo in interface Broker
See Also:
Broker.getBrokerInfo()

setBrokercontainer

protected void setBrokercontainer(BrokerContainerImpl container)

getBrokerContainer

protected BrokerContainerImpl getBrokerContainer()


Copyright © 2004-2008 Protique, Ltd.. All Rights Reserved.