org.activemq
Class ActiveMQConnectionFactory

java.lang.Object
  extended by org.activemq.jndi.JNDIBaseStorable
      extended by org.activemq.ActiveMQConnectionFactory
All Implemented Interfaces:
ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory, Referenceable, JNDIStorableInterface, StatsCapable, Service
Direct Known Subclasses:
ActiveMQXAConnectionFactory

public class ActiveMQConnectionFactory
extends JNDIBaseStorable
implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory, Service, StatsCapable

A ConnectionFactory is an an Administed object, and is used for creating Connections.

This class also implements QueueConnectionFactory and TopicConnectionFactory and is an Administered object. You can use this connection to create both QueueConnections and TopicConnections.

Version:
$Revision: 1.2 $
See Also:
ConnectionFactory

Field Summary
protected  BrokerContainer brokerContainer
           
protected  String brokerName
           
protected  String brokerURL
           
protected  boolean cachingEnabled
           
protected  String clientID
           
protected  boolean copyMessageOnSend
           
protected  boolean disableTimeStampsByDefault
           
protected  boolean doMessageCompression
           
protected  boolean doMessageFragmentation
           
protected  boolean internalConnection
           
protected  boolean J2EEcompliant
           
protected  int messageCompressionLevel
           
protected  int messageCompressionLimit
           
protected  int messageCompressionStrategy
           
protected  int messageFragmentationLimit
           
protected  boolean optimizedMessageDispatch
           
protected  String password
           
protected  boolean prepareMessageBodyOnSend
           
protected  boolean quickClose
           
protected  boolean useAsyncSend
          Should we use an async send for persistent non transacted messages ?
protected  String userName
           
 
Constructor Summary
ActiveMQConnectionFactory()
          Default Constructor for ActiveMQConnectionFactory
ActiveMQConnectionFactory(BrokerContainer container)
          Constructs a ConnectionFactory with an already configured and started BrokerContainer ready for use in embedded mode.
ActiveMQConnectionFactory(BrokerContainer container, String brokerURL)
          Constructs a ConnectionFactory with an already configured and started BrokerContainer ready for use in embedded mode and the brokerURL connection.
ActiveMQConnectionFactory(String brokerURL)
           
ActiveMQConnectionFactory(String userName, String password, String brokerURL)
           
 
Method Summary
protected  void buildFromProperties(Properties props)
          Set the properties that will represent the instance in JNDI
protected  BrokerConnector createBrokerConnector(String url)
           
protected  BrokerContainerFactory createBrokerContainerFactory()
           
 Connection createConnection()
          Create a JMS Connection
 Connection createConnection(String userName, String password)
           
protected  String createMulticastClientID()
          Creates the clientID for the multicast client (used to dispatch local messages over a multicast bus)
 QueueConnection createQueueConnection()
          Create a JMS QueueConnection
 QueueConnection createQueueConnection(String userName, String password)
           
 TopicConnection createTopicConnection()
          Create a JMS TopicConnection
 TopicConnection createTopicConnection(String userName, String password)
           
protected  TransportChannel createTransportChannel(String theURLString)
          Factory method to create a TransportChannel from a URL
protected  URI createURI(String uri)
           
protected  URI createURI(String protocol, URI uri)
           
protected  TransportChannel ensureMulticastChannelIsAvailable(URI remoteLocation, TransportChannel channel, BrokerConnector brokerConnector, boolean created)
           
protected  TransportChannel ensureServerIsAvailable(URI remoteLocation, TransportChannel channel, BrokerConnector brokerConnector, boolean created)
           
protected  boolean getBoolean(Properties props, String key)
          Helper method to return the property value as a boolean flag
protected  boolean getBoolean(Properties props, String key, boolean defaultValue)
          Helper method to return the property value as a boolean flag
 BrokerContainer getBrokerContainer()
           
 BrokerContainerFactory getBrokerContainerFactory()
           
 BrokerContext getBrokerContext()
          Returns the context used to store broker containers and connectors which defaults to using the singleton
 String getBrokerName()
          The name of the broker to use if creating an embedded broker
 String getBrokerName(String url)
          The name of the broker to use if creating an embedded broker
 String getBrokerURL()
           
 String getBrokerXmlConfig()
           
 String getClientID()
           
protected  BrokerContainer getContainer(String url, String name)
           
 Broker getEmbeddedBroker()
           
 JMSStatsImpl getFactoryStats()
           
 int getMessageCompressionLimit()
           
 int getMessageCompressionStrategy()
           
 int getMessageFragmentationLimit()
           
 String getPassword()
           
 ActiveMQPrefetchPolicy getPrefetchPolicy()
          Allows the prefetch policy to be configured
 StatsImpl getStats()
           
 String getUserName()
           
 WireFormat getWireFormat()
           
 boolean isCachingEnabled()
           
 boolean isCopyMessageOnSend()
           
 boolean isDisableTimeStampsByDefault()
           
 boolean isDoMessageCompression()
           
 boolean isDoMessageFragmentation()
           
 boolean isInternalConnection()
           
 boolean isJ2EEcompliant()
           
 boolean isOptimizedMessageDispatch()
           
 boolean isPrepareMessageBodyOnSend()
          Causes pre-serialization of messages before send By default this is on
 boolean isQuickClose()
           
 boolean isTurboBoost()
           
 boolean isUseAsyncSend()
           
 boolean isUseEmbeddedBroker()
          Is an embedded broker used by this connection factory
protected  void populateProperties(Properties props)
          Initialize the instance from properties stored in JNDI
static void registerBroker(String theURLString, BrokerConnector brokerConnector)
           
 void setBrokerContainerFactory(BrokerContainerFactory brokerContainerFactory)
           
 void setBrokerContext(BrokerContext brokerContext)
           
 void setBrokerName(String brokerName)
           
 void setBrokerURL(String brokerURL)
           
 void setBrokerXmlConfig(String brokerXmlConfig)
          Sets the XML configuration file used to configure the ActiveMQ broker via Spring if using embedded mode.
 void setCachingEnabled(boolean cachingEnabled)
           
 void setClientID(String clientID)
           
 void setCopyMessageOnSend(boolean copyMessageOnSend)
           
 void setDisableTimeStampsByDefault(boolean disableTimeStampsByDefault)
           
 void setDoMessageCompression(boolean doMessageCompression)
           
 void setDoMessageFragmentation(boolean doMessageFragmentation)
           
 void setInternalConnection(boolean internalConnection)
           
 void setJ2EEcompliant(boolean ecompliant)
           
 void setMessageCompressionLimit(int messageCompressionLimit)
           
 void setMessageCompressionStrategy(int messageCompressionStrategy)
           
 void setMessageFragmentationLimit(int messageFragmentationLimit)
           
 void setOptimizedMessageDispatch(boolean optimizedMessageDispatch)
           
 void setPassword(String password)
           
 void setPrefetchPolicy(ActiveMQPrefetchPolicy prefetchPolicy)
          Sets the prefetch policy
 void setPrepareMessageBodyOnSend(boolean prePrepareMessageOnSend)
          Causes pre-serialization of messages before send By default this is on
 void setQuickClose(boolean quickClose)
           
 void setTurboBoost(boolean value)
          Set this flag for fast throughput!
 void setUseAsyncSend(boolean useAsyncSend)
           
 void setUseEmbeddedBroker(boolean useEmbeddedBroker)
          Allows embedded brokers to be associated with a connection factory
 void setUserName(String userName)
           
 void setWireFormat(String format)
          set the WireFormat by name - e.g.
 void setWireFormat(WireFormat wireFormat)
          Allows a custom wire format to be used; otherwise the default Java wire format is used which is designed for minimum size and maximum speed on the Java platform
 void start()
          Called to start the service
 void stop()
          A hook to allow any embedded JMS Broker's to be closed down
static void unregisterBroker(String theURLString)
           
 
Methods inherited from class org.activemq.jndi.JNDIBaseStorable
getProperties, getReference, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

brokerContainer

protected BrokerContainer brokerContainer

userName

protected String userName

password

protected String password

brokerURL

protected String brokerURL

clientID

protected String clientID

brokerName

protected String brokerName

useAsyncSend

protected boolean useAsyncSend
Should we use an async send for persistent non transacted messages ?


disableTimeStampsByDefault

protected boolean disableTimeStampsByDefault

J2EEcompliant

protected boolean J2EEcompliant

doMessageCompression

protected boolean doMessageCompression

messageCompressionLimit

protected int messageCompressionLimit

messageCompressionLevel

protected int messageCompressionLevel

messageCompressionStrategy

protected int messageCompressionStrategy

doMessageFragmentation

protected boolean doMessageFragmentation

messageFragmentationLimit

protected int messageFragmentationLimit

cachingEnabled

protected boolean cachingEnabled

prepareMessageBodyOnSend

protected boolean prepareMessageBodyOnSend

quickClose

protected boolean quickClose

internalConnection

protected boolean internalConnection

optimizedMessageDispatch

protected boolean optimizedMessageDispatch

copyMessageOnSend

protected boolean copyMessageOnSend
Constructor Detail

ActiveMQConnectionFactory

public ActiveMQConnectionFactory()
Default Constructor for ActiveMQConnectionFactory


ActiveMQConnectionFactory

public ActiveMQConnectionFactory(String brokerURL)

ActiveMQConnectionFactory

public ActiveMQConnectionFactory(String userName,
                                 String password,
                                 String brokerURL)

ActiveMQConnectionFactory

public ActiveMQConnectionFactory(BrokerContainer container)
Constructs a ConnectionFactory with an already configured and started BrokerContainer ready for use in embedded mode.

Parameters:
container -

ActiveMQConnectionFactory

public ActiveMQConnectionFactory(BrokerContainer container,
                                 String brokerURL)
Constructs a ConnectionFactory with an already configured and started BrokerContainer ready for use in embedded mode and the brokerURL connection.

Parameters:
container -
Method Detail

getStats

public StatsImpl getStats()
Specified by:
getStats in interface StatsCapable
Returns:
the Stats for this object

getFactoryStats

public JMSStatsImpl getFactoryStats()

getBrokerURL

public String getBrokerURL()
Returns:
Returns the brokerURL.

setBrokerURL

public void setBrokerURL(String brokerURL)
Parameters:
brokerURL - The brokerURL to set.

getClientID

public String getClientID()
Returns:
Returns the clientID.

setClientID

public void setClientID(String clientID)
Parameters:
clientID - The clientID to set.

getPassword

public String getPassword()
Returns:
Returns the password.

setPassword

public void setPassword(String password)
Parameters:
password - The password to set.

getUserName

public String getUserName()
Returns:
Returns the userName.

setUserName

public void setUserName(String userName)
Parameters:
userName - The userName to set.

isUseEmbeddedBroker

public boolean isUseEmbeddedBroker()
Is an embedded broker used by this connection factory

Returns:
true if an embedded broker will be used by this connection factory

setUseEmbeddedBroker

public void setUseEmbeddedBroker(boolean useEmbeddedBroker)
Allows embedded brokers to be associated with a connection factory

Parameters:
useEmbeddedBroker -

getBrokerName

public String getBrokerName()
The name of the broker to use if creating an embedded broker

Returns:

getBrokerName

public String getBrokerName(String url)
The name of the broker to use if creating an embedded broker

Returns:

setBrokerName

public void setBrokerName(String brokerName)

isUseAsyncSend

public boolean isUseAsyncSend()
Returns:
Returns the useAsyncSend.

setUseAsyncSend

public void setUseAsyncSend(boolean useAsyncSend)
Parameters:
useAsyncSend - The useAsyncSend to set.

getWireFormat

public WireFormat getWireFormat()

getPrefetchPolicy

public ActiveMQPrefetchPolicy getPrefetchPolicy()
Allows the prefetch policy to be configured

Returns:

setPrefetchPolicy

public void setPrefetchPolicy(ActiveMQPrefetchPolicy prefetchPolicy)
Sets the prefetch policy

Parameters:
prefetchPolicy -

setTurboBoost

public void setTurboBoost(boolean value)
Set this flag for fast throughput!

Enables asynchronous sending of messages and disables timestamps by default

Parameters:
value - - the flag to set

isTurboBoost

public boolean isTurboBoost()
Returns:
true if turboBoost enabled

isOptimizedMessageDispatch

public boolean isOptimizedMessageDispatch()
Returns:
Returns the optimizedMessageDispatch.

setOptimizedMessageDispatch

public void setOptimizedMessageDispatch(boolean optimizedMessageDispatch)
Parameters:
optimizedMessageDispatch - The optimizedMessageDispatch to set.

isDisableTimeStampsByDefault

public boolean isDisableTimeStampsByDefault()
Returns:
Returns the disableTimeStampsByDefault.

setDisableTimeStampsByDefault

public void setDisableTimeStampsByDefault(boolean disableTimeStampsByDefault)
Parameters:
disableTimeStampsByDefault - The disableTimeStampsByDefault to set.

isJ2EEcompliant

public boolean isJ2EEcompliant()
Returns:
Returns the j2EEcompliant.

setJ2EEcompliant

public void setJ2EEcompliant(boolean ecompliant)
Parameters:
ecompliant - The j2EEcompliant to set.

isInternalConnection

public boolean isInternalConnection()
Returns:
Returns the internalConnection.

setInternalConnection

public void setInternalConnection(boolean internalConnection)
Parameters:
internalConnection - The internalConnection to set.

isQuickClose

public boolean isQuickClose()
Returns:
Returns the quickClose.

setQuickClose

public void setQuickClose(boolean quickClose)
Parameters:
quickClose - The quickClose to set.

isDoMessageCompression

public boolean isDoMessageCompression()
Returns:
Returns the doMessageCompression.

setDoMessageCompression

public void setDoMessageCompression(boolean doMessageCompression)
Parameters:
doMessageCompression - The doMessageCompression to set.

isDoMessageFragmentation

public boolean isDoMessageFragmentation()
Returns:
Returns the doMessageFragmentation.

setDoMessageFragmentation

public void setDoMessageFragmentation(boolean doMessageFragmentation)
Parameters:
doMessageFragmentation - The doMessageFragmentation to set.

getMessageCompressionLimit

public int getMessageCompressionLimit()
Returns:
Returns the messageCompressionLimit.

setMessageCompressionLimit

public void setMessageCompressionLimit(int messageCompressionLimit)
Parameters:
messageCompressionLimit - The messageCompressionLimit to set.

getMessageCompressionStrategy

public int getMessageCompressionStrategy()
Returns:
Returns the messageCompressionStrategy.

setMessageCompressionStrategy

public void setMessageCompressionStrategy(int messageCompressionStrategy)
Parameters:
messageCompressionStrategy - The messageCompressionStrategy to set.

getMessageFragmentationLimit

public int getMessageFragmentationLimit()
Returns:
Returns the messageFragmentationLimit.

setMessageFragmentationLimit

public void setMessageFragmentationLimit(int messageFragmentationLimit)
Parameters:
messageFragmentationLimit - The messageFragmentationLimit to set.

isCachingEnabled

public boolean isCachingEnabled()
Returns:
Returns the cachingEnabled.

setCachingEnabled

public void setCachingEnabled(boolean cachingEnabled)
Parameters:
cachingEnabled - The cachingEnabled to set.

isPrepareMessageBodyOnSend

public boolean isPrepareMessageBodyOnSend()
Causes pre-serialization of messages before send By default this is on

Returns:
Returns the prePrepareMessageOnSend.

setPrepareMessageBodyOnSend

public void setPrepareMessageBodyOnSend(boolean prePrepareMessageOnSend)
Causes pre-serialization of messages before send By default this is on

Parameters:
prePrepareMessageOnSend - The prePrepareMessageOnSend to set.

isCopyMessageOnSend

public boolean isCopyMessageOnSend()
Returns:
Returns the copyMessageOnSend.

setCopyMessageOnSend

public void setCopyMessageOnSend(boolean copyMessageOnSend)
Parameters:
copyMessageOnSend - The copyMessageOnSend to set.

setWireFormat

public void setWireFormat(WireFormat wireFormat)
Allows a custom wire format to be used; otherwise the default Java wire format is used which is designed for minimum size and maximum speed on the Java platform

Parameters:
wireFormat -

setWireFormat

public void setWireFormat(String format)
                   throws JMSException
set the WireFormat by name - e.g. 'default','amqpfast' etc.

Parameters:
format -
Throws:
JMSException

getBrokerXmlConfig

public String getBrokerXmlConfig()

getBrokerContainer

public BrokerContainer getBrokerContainer()

setBrokerXmlConfig

public void setBrokerXmlConfig(String brokerXmlConfig)
Sets the XML configuration file used to configure the ActiveMQ broker via Spring if using embedded mode.

Parameters:
brokerXmlConfig - is the filename which is assumed to be on the classpath unless a URL is specified. So a value of foo/bar.xml would be assumed to be on the classpath whereas file:dir/file.xml would use the file system. Any valid URL string is supported.
See Also:
setUseEmbeddedBroker(boolean)

getBrokerContainerFactory

public BrokerContainerFactory getBrokerContainerFactory()
                                                 throws JMSException
Throws:
JMSException

setBrokerContainerFactory

public void setBrokerContainerFactory(BrokerContainerFactory brokerContainerFactory)

getBrokerContext

public BrokerContext getBrokerContext()
Returns the context used to store broker containers and connectors which defaults to using the singleton


setBrokerContext

public void setBrokerContext(BrokerContext brokerContext)

createConnection

public Connection createConnection()
                            throws JMSException
Create a JMS Connection

Specified by:
createConnection in interface ConnectionFactory
Returns:
the JMS Connection
Throws:
JMSException - if an error occurs creating the Connection

createConnection

public Connection createConnection(String userName,
                                   String password)
                            throws JMSException
Specified by:
createConnection in interface ConnectionFactory
Parameters:
userName -
password -
Returns:
the Connection
Throws:
JMSException - if an error occurs creating the Connection

createQueueConnection

public QueueConnection createQueueConnection()
                                      throws JMSException
Create a JMS QueueConnection

Specified by:
createQueueConnection in interface QueueConnectionFactory
Returns:
the JMS QueueConnection
Throws:
JMSException - if an error occurs creating the Connection

createQueueConnection

public QueueConnection createQueueConnection(String userName,
                                             String password)
                                      throws JMSException
Specified by:
createQueueConnection in interface QueueConnectionFactory
Parameters:
userName -
password -
Returns:
the QueueConnection
Throws:
JMSException - if an error occurs creating the Connection

createTopicConnection

public TopicConnection createTopicConnection()
                                      throws JMSException
Create a JMS TopicConnection

Specified by:
createTopicConnection in interface TopicConnectionFactory
Returns:
the JMS TopicConnection
Throws:
JMSException - if an error occurs creating the Connection

createTopicConnection

public TopicConnection createTopicConnection(String userName,
                                             String password)
                                      throws JMSException
Specified by:
createTopicConnection in interface TopicConnectionFactory
Parameters:
userName -
password -
Returns:
the TopicConnection
Throws:
JMSException - if an error occurs creating the Connection

start

public void start()
           throws JMSException
Description copied from interface: Service
Called to start the service

Specified by:
start in interface Service
Throws:
JMSException

stop

public void stop()
          throws JMSException
A hook to allow any embedded JMS Broker's to be closed down

Specified by:
stop in interface Service
Throws:
JMSException

getEmbeddedBroker

public Broker getEmbeddedBroker()
                         throws JMSException
Throws:
JMSException

registerBroker

public static void registerBroker(String theURLString,
                                  BrokerConnector brokerConnector)

unregisterBroker

public static void unregisterBroker(String theURLString)

buildFromProperties

protected void buildFromProperties(Properties props)
Set the properties that will represent the instance in JNDI

Specified by:
buildFromProperties in class JNDIBaseStorable
Parameters:
props -

populateProperties

protected void populateProperties(Properties props)
Initialize the instance from properties stored in JNDI

Specified by:
populateProperties in class JNDIBaseStorable
Parameters:
props -

getBoolean

protected boolean getBoolean(Properties props,
                             String key)
Helper method to return the property value as a boolean flag

Parameters:
props -
key -
Returns:

getBoolean

protected boolean getBoolean(Properties props,
                             String key,
                             boolean defaultValue)
Helper method to return the property value as a boolean flag

Parameters:
props -
key -
defaultValue -
Returns:

createBrokerContainerFactory

protected BrokerContainerFactory createBrokerContainerFactory()
                                                       throws JMSException
Throws:
JMSException

createTransportChannel

protected TransportChannel createTransportChannel(String theURLString)
                                           throws JMSException
Factory method to create a TransportChannel from a URL

Parameters:
theURLString -
Returns:
the TransportChannel to use with the embedded broker
Throws:
JMSException

getContainer

protected BrokerContainer getContainer(String url,
                                       String name)
                                throws JMSException
Throws:
JMSException

createBrokerConnector

protected BrokerConnector createBrokerConnector(String url)
                                         throws JMSException
Throws:
JMSException

ensureServerIsAvailable

protected TransportChannel ensureServerIsAvailable(URI remoteLocation,
                                                   TransportChannel channel,
                                                   BrokerConnector brokerConnector,
                                                   boolean created)
                                            throws JMSException
Throws:
JMSException

ensureMulticastChannelIsAvailable

protected TransportChannel ensureMulticastChannelIsAvailable(URI remoteLocation,
                                                             TransportChannel channel,
                                                             BrokerConnector brokerConnector,
                                                             boolean created)
                                                      throws JMSException
Throws:
JMSException

createMulticastClientID

protected String createMulticastClientID()
Creates the clientID for the multicast client (used to dispatch local messages over a multicast bus)


createURI

protected URI createURI(String protocol,
                        URI uri)
                 throws JMSException
Throws:
JMSException

createURI

protected URI createURI(String uri)
                 throws JMSException
Throws:
JMSException


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