org.codehaus.activemq.broker.impl
Class DefaultBroker

java.lang.Object
  extended byorg.codehaus.activemq.capacity.DelegateCapacityMonitor
      extended byorg.codehaus.activemq.broker.impl.DefaultBroker
All Implemented Interfaces:
Broker, CapacityMonitor, Service

public class DefaultBroker
extends DelegateCapacityMonitor
implements Broker

The default Broker implementation

Version:
$Revision: 1.22 $

Nested Class Summary
 
Nested classes inherited from class org.codehaus.activemq.capacity.CapacityMonitor
CapacityMonitor.BasicCapacityMonitor
 
Field Summary
protected static Class[] NEWINSTANCE_PARAMETER_TYPES
           
protected static String PERSISTENCE_ADAPTER_PROPERTY
           
protected static String PROPERTY_STORE_DIRECTORY
           
 
Fields inherited from class org.codehaus.activemq.capacity.DelegateCapacityMonitor
 
Constructor Summary
DefaultBroker(String brokerName)
           
DefaultBroker(String brokerName, PersistenceAdapter persistenceAdapter)
           
DefaultBroker(String brokerName, String brokerClusterName)
           
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 acknowledgeTransactedMessage(BrokerClient client, String transactionId, MessageAck ack)
          Acknowledge consumption of a message within a transaction
 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(Class adapterClass, Throwable e)
           
protected  PersistenceAdapter createPersistenceAdapter()
          Factory method to create a default persistence adapter
 void deleteSubscription(String clientId, String subscriberName)
          Delete a durable subscriber
protected  void doMessageSend(BrokerClient client, ActiveMQMessage message)
           
protected  void fireConsumerInfo(BrokerClient client, ConsumerInfo info)
           
 String getBrokerClusterName()
           
 String getBrokerName()
           
 Map getContainerManagerMap()
           
 MessageContainerManager[] getContainerManagers()
           
 Context getDestinationContext(Hashtable environment)
          Returns the naming context of the destinations available in this broker
 long getMaximumMemoryUsage()
           
 PersistenceAdapter getPersistenceAdapter()
           
 MessageContainerManager getPersistentQueueContainerManager()
           
 MessageContainerManager getPersistentTopicContainerManager()
           
 ActiveMQXid[] getPreparedTransactions(BrokerClient client)
          Gets the prepared XA transactions.
 PreparedTransactionStore getPreparedTransactionStore()
           
 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()
           
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 redeliverMessage(BrokerClient client, MessageAck ack)
          Called after a rollback of a JMS transaction to redeliver the message to the consumers dispatch queue
 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 sendTransactedMessage(BrokerClient client, String transactionId, ActiveMQMessage message)
          send a message to the broker within a transaction
 void setContainerManagerMap(Map containerManagerMap)
           
 void setMaximumMemoryUsage(long maximumMemoryUsage)
           
 void setPersistenceAdapter(PersistenceAdapter persistenceAdapter)
          set the persistence adaptor
 void setPreparedTransactionStore(PreparedTransactionStore preparedTransactionStore)
           
 void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
           
 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
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.codehaus.activemq.capacity.DelegateCapacityMonitor
addCapacityEventListener, getCurrentCapacity, getCurrentValue, getName, getRoundedCapacity, getRoundingFactor, getValueLimit, removeCapacityEventListener, setCurrentValue, setDelegate, setName, setRoundingFactor, setValueLimit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.codehaus.activemq.capacity.CapacityMonitor
addCapacityEventListener, getCurrentCapacity, getCurrentValue, getName, 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_PROPERTY

protected static final String PERSISTENCE_ADAPTER_PROPERTY
See Also:
Constant Field Values

NEWINSTANCE_PARAMETER_TYPES

protected static final Class[] NEWINSTANCE_PARAMETER_TYPES
Constructor Detail

DefaultBroker

public DefaultBroker(String brokerName,
                     String brokerClusterName)

DefaultBroker

public DefaultBroker(String brokerName)

DefaultBroker

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

DefaultBroker

public DefaultBroker(String brokerName,
                     PersistenceAdapter persistenceAdapter)
Method Detail

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

sendTransactedMessage

public void sendTransactedMessage(BrokerClient client,
                                  String transactionId,
                                  ActiveMQMessage message)
                           throws JMSException
send a message to the broker within a transaction

Specified by:
sendTransactedMessage 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

acknowledgeTransactedMessage

public void acknowledgeTransactedMessage(BrokerClient client,
                                         String transactionId,
                                         MessageAck ack)
                                  throws JMSException
Acknowledge consumption of a message within a transaction

Specified by:
acknowledgeTransactedMessage in interface Broker
Throws:
JMSException

redeliverMessage

public void redeliverMessage(BrokerClient client,
                             MessageAck ack)
                      throws JMSException
Description copied from interface: Broker
Called after a rollback of a JMS transaction to redeliver the message to the consumers dispatch queue

Specified by:
redeliverMessage in interface Broker
Parameters:
client -
ack -
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
Parameters:
clientId -
subscriberName -
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
Parameters:
client -
transactionId -
Throws:
JMSException
See Also:
Broker.startTransaction(org.codehaus.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
Parameters:
client -
transactionId -
Throws:
JMSException

rollbackTransaction

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

Specified by:
rollbackTransaction in interface Broker
Parameters:
client -
transactionId -
Throws:
JMSException

startTransaction

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

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

prepareTransaction

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

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

rollbackTransaction

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

Specified by:
rollbackTransaction in interface Broker
Parameters:
client -
xid -
Throws:
XAException
See Also:
Broker.rollbackTransaction(org.codehaus.activemq.broker.BrokerClient, org.codehaus.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
Parameters:
client -
xid -
onePhase -
Throws:
XAException
See Also:
Broker.commitTransaction(org.codehaus.activemq.broker.BrokerClient, org.codehaus.activemq.message.ActiveMQXid, boolean)

getPreparedTransactions

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

Specified by:
getPreparedTransactions in interface Broker
Parameters:
client -
Throws:
XAException
See Also:
Broker.getPreparedTransactions(org.codehaus.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
Parameters:
persistenceAdapter -

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

setRedeliveryPolicy

public void setRedeliveryPolicy(RedeliveryPolicy redeliveryPolicy)
Specified by:
setRedeliveryPolicy in interface Broker

getPreparedTransactionStore

public PreparedTransactionStore getPreparedTransactionStore()

setPreparedTransactionStore

public void setPreparedTransactionStore(PreparedTransactionStore preparedTransactionStore)

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
Parameters:
environment -
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(Class adapterClass,
                                                         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


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