Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.activemq
Class ActiveMQConnection  view ActiveMQConnection download ActiveMQConnection.java

java.lang.Object
  extended byorg.activemq.ActiveMQConnection
All Implemented Interfaces:
org.activemq.capacity.CapacityMonitorEventListener, Closeable, javax.jms.Connection, javax.jms.ExceptionListener, org.activemq.message.PacketListener, javax.jms.QueueConnection, org.activemq.management.StatsCapable, javax.jms.TopicConnection, org.activemq.transport.TransportStatusEventListener
Direct Known Subclasses:
ActiveMQXAConnection

public class ActiveMQConnection
extends java.lang.Object
implements javax.jms.Connection, org.activemq.message.PacketListener, javax.jms.ExceptionListener, javax.jms.TopicConnection, javax.jms.QueueConnection, org.activemq.management.StatsCapable, org.activemq.capacity.CapacityMonitorEventListener, org.activemq.transport.TransportStatusEventListener, Closeable

A Connection object is a client's active connection to its JMS provider. It typically allocates provider resources outside the Java virtual machine (JVM).

Connections support concurrent use.

A connection serves several purposes:

Because the creation of a connection involves setting up authentication and communication, a connection is a relatively heavyweight object. Most clients will do all their messaging with a single connection. Other more advanced applications may use several connections. The JMS API does not architect a reason for using multiple connections; however, there may be operational reasons for doing so.

A JMS client typically creates a connection, one or more sessions, and a number of message producers and consumers. When a connection is created, it is in stopped mode. That means that no messages are being delivered.

It is typical to leave the connection in stopped mode until setup is complete (that is, until all message consumers have been created). At that point, the client calls the connection's start method, and messages begin arriving at the connection's consumers. This setup convention minimizes any client confusion that may result from asynchronous message delivery while the client is still in the process of setting itself up.

A connection can be started immediately, and the setup can be done afterwards. Clients that do this must be prepared to handle asynchronous message delivery while they are still in the process of setting up.

A message producer can send messages while a connection is stopped.

This class is also a TopicConnection . A TopicConnection object is an active connection to a publish/subscribe JMS provider. A client uses a TopicConnection object to create one or more TopicSession objects for producing and consuming messages.

A TopicConnection can be used to create a TopicSession, from which specialized topic-related objects can be created. A more general, and recommended approach is to use the Connection object.

This class is also a QueueConnection. A A QueueConnection object is an active connection to a point-to-point JMS provider. A client uses a QueueConnection object to create one or more QueueSession objects for producing and consuming messages.

A QueueConnection can be used to create a QueueSession, from which specialized queue-related objects can be created. A more general, and recommended, approach is to use the Connection object.

A QueueConnection cannot be used to create objects specific to the publish/subscribe domain. The createDurableConnectionConsumer method inherits from Connection, but must throw an IllegalStateException if used from QueueConnection. // *

Version:
$Revision: 1.1.1.1 $

Field Summary
private  ConcurrentHashMap assemblies
           
private  org.activemq.io.util.MemoryBoundedQueueManager boundedQueueManager
           
private  boolean cachingEnabled
           
protected  java.lang.String clientID
           
private  org.activemq.util.IdGenerator clientIdGenerator
           
private  boolean clientIDSet
           
private  boolean closed
           
private  CopyOnWriteArrayList connectionConsumers
           
private  ActiveMQConnectionMetaData connectionMetaData
           
private  EDU.oswego.cs.dl.util.concurrent.SynchronizedInt consumerNumberGenerator
           
private  boolean copyMessageOnSend
           
static java.lang.String DEFAULT_BROKER_URL
          Default URL for the ActiveMQ Broker
private static int DEFAULT_CONNECTION_MEMORY_LIMIT
           
static java.lang.String DEFAULT_PASSWORD
          Default Password for the Connection
static java.lang.String DEFAULT_URL
          Default client URL.
static java.lang.String DEFAULT_USER
          Default UserName for the Connection
private  boolean disableTimeStampsByDefault
           
private  boolean doMessageCompression
           
private  boolean doMessageFragmentation
           
private  javax.jms.ExceptionListener exceptionListener
           
private  ActiveMQConnectionFactory factory
           
private  org.activemq.management.JMSStatsImpl factoryStats
           
private  org.activemq.filter.FilterFactory filterFactory
           
private  long flowControlSleepTime
           
private  org.activemq.io.util.ByteArrayFragmentation fragmentation
           
protected  org.activemq.util.IdGenerator handleIdGenerator
           
private  boolean internalConnection
           
private  boolean isConnectionInfoSentToBroker
           
private  boolean isTransportOK
           
private  boolean J2EEcompliant
           
private static org.apache.commons.logging.Log log
           
private  org.activemq.io.util.MemoryBoundedObjectManager memoryManager
           
private  int messageCompressionLevel
           
private  int messageCompressionLimit
           
private  int messageCompressionStrategy
           
private  CopyOnWriteArrayList messageDispatchers
           
private  int messageFragmentationLimit
           
private  boolean optimizedMessageDispatch
           
protected  org.activemq.util.IdGenerator packetIdGenerator
           
private  java.lang.String password
           
private  ActiveMQPrefetchPolicy prefetchPolicy
           
private  boolean prepareMessageBodyOnSend
           
private  boolean quickClose
           
private  java.lang.String resourceManagerId
           
private  int sendCloseTimeout
           
private  int sendConnectionInfoTimeout
           
private  org.activemq.util.IdGenerator sessionIdGenerator
           
private  CopyOnWriteArrayList sessions
           
private  SynchronizedBoolean started
           
private  boolean startedTransport
           
private  long startTime
           
private  org.activemq.management.JMSConnectionStatsImpl stats
           
private  java.util.Map tempDestinationMap
           
private  CopyOnWriteArrayList transientConsumedRedeliverCache
           
private  org.activemq.transport.TransportChannel transportChannel
           
protected  boolean useAsyncSend
          Should we use an async send for persistent non transacted messages ?
private  java.lang.String userName
           
private  boolean userSpecifiedClientID
           
private  java.util.Map validDestinationsMap
           
 
Constructor Summary
protected ActiveMQConnection(ActiveMQConnectionFactory factory, java.lang.String theUserName, java.lang.String thePassword)
           
  ActiveMQConnection(ActiveMQConnectionFactory factory, java.lang.String theUserName, java.lang.String thePassword, org.activemq.transport.TransportChannel transportChannel)
          Constructs a connection from an existing TransportChannel and user/password.
 
Method Summary
protected  void addConnectionConsumer(ActiveMQConnectionConsumer connectionConsumer)
          Add a ConnectionConsumer
protected  void addMessageDispatcher(ActiveMQMessageDispatcher messageDispatch)
          Add a Message dispatcher to receive messages from the Broker
protected  void addSession(ActiveMQSession session)
          Used internally for adding Sessions to the Connection
protected  void addToTransientConsumedRedeliverCache(org.activemq.message.ActiveMQMessage message)
           
private  org.activemq.message.ActiveMQMessage assembleMessage(org.activemq.message.ActiveMQMessage message)
           
 void asyncSendPacket(org.activemq.message.Packet packet)
          send a Packet through the Connection - for internal use only
 void asyncSendPacket(org.activemq.message.Packet packet, boolean doSendWhileReconnecting)
          send a Packet through the Connection - for internal use only
 void capacityChanged(org.activemq.capacity.CapacityMonitorEvent event)
          CapacityMonitorEventListener implementation called when the capacity of a CapacityService changes
 void changeUserInfo(java.lang.String theUserName, java.lang.String thePassword)
          Changes the associated username/password that is associated with this connection.
 void checkClientIDWasManuallySpecified()
          Ensures that the clientID was manually specified and not auto-generated.
protected  void checkClosed()
          simply throws an exception if the Connection is already closed
 void cleanup()
          Cleans up this connection so that it's state is as if the connection was just created.
protected  void clearMessagesInProgress()
           
 void close()
          Closes the connection.
protected  void closeTemporaryDestinations()
           
 void consume(org.activemq.message.Packet packet)
          Implementation of the PacketListener interface - consume a packet
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
          Creates a connection consumer for this connection (optional operation).
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages, boolean noLocal)
          Creates a connection consumer for this connection (optional operation).
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Queue queue, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
          Creates a connection consumer for this connection (optional operation).
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Topic topic, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
          Creates a connection consumer for this connection (optional operation).
 javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
          Create a durable connection consumer for this connection (optional operation).
 javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages, boolean noLocal)
          Create a durable connection consumer for this connection (optional operation).
 javax.jms.QueueSession createQueueSession(boolean transacted, int acknowledgeMode)
          Creates a QueueSession object.
 javax.jms.Session createSession(boolean transacted, int acknowledgeMode)
          Creates a Session object.
 javax.jms.Session createSession(boolean transacted, int acknowledgeMode, boolean optimizedDispatch)
          Creates a Session object.
private  org.activemq.message.SessionInfo createSessionInfo(ActiveMQSession session)
           
 javax.jms.TopicSession createTopicSession(boolean transacted, int acknowledgeMode)
          Creates a TopicSession object.
 void destroyDestination(org.activemq.message.ActiveMQDestination destination)
          Tells the broker to destroy a destination.
private  java.lang.String determineResourceManagerId()
          Get's the resource manager id.
protected  void doReconnect()
           
private  void ensureClientIDInitialised()
           
protected  short generateSessionId()
           
 ConcurrentHashMap getAssemblies()
           
 java.lang.String getClientID()
          Gets the client identifier for this connection.
 int getConnectionMemoryLimit()
          Get the current value for the maximum amount of memory this Connection should use for buffered inbound messages
 org.activemq.management.JMSConnectionStatsImpl getConnectionStats()
           
 javax.jms.ExceptionListener getExceptionListener()
          Gets the ExceptionListener object for this connection.
private  org.activemq.filter.FilterFactory getFilterFactory()
           
 org.activemq.io.util.ByteArrayFragmentation getFragmentation()
           
 java.lang.String getInitializedClientID()
          Returns the clientID of the connection, forcing one to be generated if one has not yet been configured
protected  org.activemq.io.util.MemoryBoundedQueue getMemoryBoundedQueue(java.lang.String name)
           
 int getMessageCompressionLevel()
           
 int getMessageCompressionLimit()
           
 int getMessageCompressionStrategy()
           
 int getMessageFragmentationLimit()
           
 javax.jms.ConnectionMetaData getMetaData()
          Gets the metadata for this connection.
protected  int getNextConsumerNumber()
           
 ActiveMQPrefetchPolicy getPrefetchPolicy()
           
 java.lang.String getResourceManagerId()
           
 int getSendCloseTimeout()
           
 int getSendConnectionInfoTimeout()
           
 org.activemq.management.StatsImpl getStats()
           
 org.activemq.transport.TransportChannel getTransportChannel()
           
protected  void handleAsyncException(javax.jms.JMSException jmsEx)
          Used for handling async exceptions
 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()
           
protected  boolean isStarted()
           
 boolean isUseAsyncSend()
           
static ActiveMQConnection makeConnection()
          A static helper method to create a new connection
static ActiveMQConnection makeConnection(java.lang.String uri)
          A static helper method to create a new connection
static ActiveMQConnection makeConnection(java.lang.String user, java.lang.String password, java.lang.String uri)
          A static helper method to create a new connection
 void onException(javax.jms.JMSException jmsEx)
           
protected  void removeConnectionConsumer(ActiveMQConnectionConsumer connectionConsumer)
          Remove a ConnectionConsumer
protected  void removeMessageDispatcher(ActiveMQMessageDispatcher messageDispatcher)
          Remove a Message dispatcher
protected  void removeSession(ActiveMQSession session)
          Used interanlly for removing Sessions from a Connection
protected  void replayTransientConsumedRedeliveredMessages(ActiveMQSession session, ActiveMQMessageConsumer consumer)
           
protected  void sendConnectionInfoToBroker()
           
protected  void sendConnectionInfoToBroker(int timeout, boolean forceResend, boolean closing)
          Send the ConnectionInfo to the Broker
 void setCachingEnabled(boolean cachingEnabled)
           
 void setClientID(java.lang.String newClientID)
          Sets the client identifier for this connection.
 void setConnectionMemoryLimit(int newMemoryLimit)
          Set the maximum amount of memory this Connection should use for buffered inbound messages
 void setCopyMessageOnSend(boolean copyMessageOnSend)
           
 void setDisableTimeStampsByDefault(boolean disableTimeStampsByDefault)
           
 void setDoMessageCompression(boolean doMessageCompression)
           
 void setDoMessageFragmentation(boolean doMessageFragmentation)
           
 void setExceptionListener(javax.jms.ExceptionListener listener)
          Sets an exception listener for this connection.
 void setInternalConnection(boolean internalConnection)
           
 void setJ2EEcompliant(boolean ecompliant)
           
 void setMessageCompressionLevel(int messageCompressionLevel)
           
 void setMessageCompressionLimit(int messageCompressionLimit)
           
 void setMessageCompressionStrategy(int messageCompressionStrategy)
           
 void setMessageFragmentationLimit(int messageFragmentationLimit)
           
 void setOptimizedMessageDispatch(boolean optimizedMessageDispatch)
           
 void setPrefetchPolicy(ActiveMQPrefetchPolicy prefetchPolicy)
           
 void setPrepareMessageBodyOnSend(boolean prePrepareMessageOnSend)
          Causes pre-serialization of messages before send By default this is on
 void setQuickClose(boolean quickClose)
           
 void setSendCloseTimeout(int sendCloseTimeout)
           
 void setSendConnectionInfoTimeout(int sendConnectionInfoTimeout)
           
 void setUseAsyncSend(boolean useAsyncSend)
           
 void start()
          Starts (or restarts) a connection's delivery of incoming messages.
protected  void startAdvisoryForTempDestination(javax.jms.Destination d)
           
protected  void startTemporaryDestination(org.activemq.message.ActiveMQDestination dest)
           
 void statusChanged(org.activemq.transport.TransportStatusEvent event)
          handle disconnect/reconnect events
 void stop()
          Temporarily stops a connection's delivery of incoming messages.
protected  void stopAdvisoryForTempDestination(org.activemq.message.ActiveMQDestination d)
           
protected  void stopTemporaryDestination(org.activemq.message.ActiveMQDestination dest)
           
 void syncSendPacket(org.activemq.message.Packet packet)
          send a Packet through a Connection - for internal use only
 void syncSendPacket(org.activemq.message.Packet packet, int timeout)
          Send a packet through a Connection - for internal use only
 org.activemq.message.Receipt syncSendRequest(org.activemq.message.Packet packet)
           
 void terminateBrokerVM()
          Tells the broker to terminate its VM.
protected  void validateDestination(org.activemq.message.ActiveMQDestination dest)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_USER

public static final java.lang.String DEFAULT_USER
Default UserName for the Connection

See Also:
Constant Field Values

DEFAULT_BROKER_URL

public static final java.lang.String DEFAULT_BROKER_URL
Default URL for the ActiveMQ Broker

See Also:
Constant Field Values

DEFAULT_URL

public static final java.lang.String DEFAULT_URL
Default client URL. If using a message broker in a hub(s)/spoke architecture - use the DEFAULT_BROKER_URL

See Also:
DEFAULT_BROKER_URL 55 , Constant Field Values

DEFAULT_PASSWORD

public static final java.lang.String DEFAULT_PASSWORD
Default Password for the Connection

See Also:
Constant Field Values

log

private static final org.apache.commons.logging.Log log

DEFAULT_CONNECTION_MEMORY_LIMIT

private static final int DEFAULT_CONNECTION_MEMORY_LIMIT
See Also:
Constant Field Values

factory

private ActiveMQConnectionFactory factory

userName

private java.lang.String userName

password

private java.lang.String password

clientID

protected java.lang.String clientID

sendCloseTimeout

private int sendCloseTimeout

transportChannel

private org.activemq.transport.TransportChannel transportChannel

exceptionListener

private javax.jms.ExceptionListener exceptionListener

prefetchPolicy

private ActiveMQPrefetchPolicy prefetchPolicy

factoryStats

private org.activemq.management.JMSStatsImpl factoryStats

memoryManager

private org.activemq.io.util.MemoryBoundedObjectManager memoryManager

boundedQueueManager

private org.activemq.io.util.MemoryBoundedQueueManager boundedQueueManager

handleIdGenerator

protected org.activemq.util.IdGenerator handleIdGenerator

clientIdGenerator

private org.activemq.util.IdGenerator clientIdGenerator

packetIdGenerator

protected org.activemq.util.IdGenerator packetIdGenerator

sessionIdGenerator

private org.activemq.util.IdGenerator sessionIdGenerator

stats

private org.activemq.management.JMSConnectionStatsImpl stats

sessions

private CopyOnWriteArrayList sessions

messageDispatchers

private CopyOnWriteArrayList messageDispatchers

connectionConsumers

private CopyOnWriteArrayList connectionConsumers

consumerNumberGenerator

private EDU.oswego.cs.dl.util.concurrent.SynchronizedInt consumerNumberGenerator

connectionMetaData

private ActiveMQConnectionMetaData connectionMetaData

closed

private boolean closed

started

private SynchronizedBoolean started

clientIDSet

private boolean clientIDSet

isConnectionInfoSentToBroker

private boolean isConnectionInfoSentToBroker

isTransportOK

private boolean isTransportOK

startedTransport

private boolean startedTransport

startTime

private long startTime

flowControlSleepTime

private long flowControlSleepTime

quickClose

private boolean quickClose

internalConnection

private boolean internalConnection

userSpecifiedClientID

private boolean userSpecifiedClientID

useAsyncSend

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


sendConnectionInfoTimeout

private int sendConnectionInfoTimeout

disableTimeStampsByDefault

private boolean disableTimeStampsByDefault

J2EEcompliant

private boolean J2EEcompliant

prepareMessageBodyOnSend

private boolean prepareMessageBodyOnSend

copyMessageOnSend

private boolean copyMessageOnSend

doMessageCompression

private boolean doMessageCompression

messageCompressionLimit

private int messageCompressionLimit

messageCompressionLevel

private int messageCompressionLevel

messageCompressionStrategy

private int messageCompressionStrategy

doMessageFragmentation

private boolean doMessageFragmentation

messageFragmentationLimit

private int messageFragmentationLimit

cachingEnabled

private boolean cachingEnabled

optimizedMessageDispatch

private boolean optimizedMessageDispatch

transientConsumedRedeliverCache

private CopyOnWriteArrayList transientConsumedRedeliverCache

filterFactory

private org.activemq.filter.FilterFactory filterFactory

tempDestinationMap

private java.util.Map tempDestinationMap

validDestinationsMap

private java.util.Map validDestinationsMap

resourceManagerId

private java.lang.String resourceManagerId

assemblies

private final ConcurrentHashMap assemblies

fragmentation

private final org.activemq.io.util.ByteArrayFragmentation fragmentation
Constructor Detail

ActiveMQConnection

public ActiveMQConnection(ActiveMQConnectionFactory factory,
                          java.lang.String theUserName,
                          java.lang.String thePassword,
                          org.activemq.transport.TransportChannel transportChannel)
                   throws javax.jms.JMSException
Constructs a connection from an existing TransportChannel and user/password.


ActiveMQConnection

protected ActiveMQConnection(ActiveMQConnectionFactory factory,
                             java.lang.String theUserName,
                             java.lang.String thePassword)
Method Detail

makeConnection

public static ActiveMQConnection makeConnection()
                                         throws javax.jms.JMSException
A static helper method to create a new connection


makeConnection

public static ActiveMQConnection makeConnection(java.lang.String uri)
                                         throws javax.jms.JMSException
A static helper method to create a new connection


makeConnection

public static ActiveMQConnection makeConnection(java.lang.String user,
                                                java.lang.String password,
                                                java.lang.String uri)
                                         throws javax.jms.JMSException
A static helper method to create a new connection


getStats

public org.activemq.management.StatsImpl getStats()
Specified by:
getStats in interface org.activemq.management.StatsCapable

getConnectionStats

public org.activemq.management.JMSConnectionStatsImpl getConnectionStats()

createSession

public javax.jms.Session createSession(boolean transacted,
                                       int acknowledgeMode)
                                throws javax.jms.JMSException
Creates a Session object.

Specified by:
createSession in interface javax.jms.Connection
Since:
1.1

createSession

public javax.jms.Session createSession(boolean transacted,
                                       int acknowledgeMode,
                                       boolean optimizedDispatch)
                                throws javax.jms.JMSException
Creates a Session object.

Since:
1.1

getClientID

public java.lang.String getClientID()
                             throws javax.jms.JMSException
Gets the client identifier for this connection.

This value is specific to the JMS provider. It is either preconfigured by an administrator in a ConnectionFactory object or assigned dynamically by the application by calling the setClientID method.

Specified by:
getClientID in interface javax.jms.Connection

setClientID

public void setClientID(java.lang.String newClientID)
                 throws javax.jms.JMSException
Sets the client identifier for this connection.

The preferred way to assign a JMS client's client identifier is for it to be configured in a client-specific ConnectionFactory object and transparently assigned to the Connection object it creates.

Alternatively, a client can set a connection's client identifier using a provider-specific value. The facility to set a connection's client identifier explicitly is not a mechanism for overriding the identifier that has been administratively configured. It is provided for the case where no administratively specified identifier exists. If one does exist, an attempt to change it by setting it must throw an IllegalStateException. If a client sets the client identifier explicitly, it must do so immediately after it creates the connection and before any other action on the connection is taken. After this point, setting the client identifier is a programming error that should throw an IllegalStateException.

The purpose of the client identifier is to associate a connection and its objects with a state maintained on behalf of the client by a provider. The only such state identified by the JMS API is that required to support durable subscriptions.

If another connection with the same clientID is already running when this method is called, the JMS provider should detect the duplicate ID and throw an InvalidClientIDException.

Specified by:
setClientID in interface javax.jms.Connection

getMetaData

public javax.jms.ConnectionMetaData getMetaData()
                                         throws javax.jms.JMSException
Gets the metadata for this connection.

Specified by:
getMetaData in interface javax.jms.Connection

getExceptionListener

public javax.jms.ExceptionListener getExceptionListener()
                                                 throws javax.jms.JMSException
Gets the ExceptionListener object for this connection. Not every Connection has an ExceptionListener associated with it.

Specified by:
getExceptionListener in interface javax.jms.Connection

setExceptionListener

public void setExceptionListener(javax.jms.ExceptionListener listener)
                          throws javax.jms.JMSException
Sets an exception listener for this connection.

If a JMS provider detects a serious problem with a connection, it informs the connection's ExceptionListener, if one has been registered. It does this by calling the listener's onException method, passing it a JMSException object describing the problem.

An exception listener allows a client to be notified of a problem asynchronously. Some connections only consume messages, so they would have no other way to learn their connection has failed.

A connection serializes execution of its ExceptionListener.

A JMS provider should attempt to resolve connection problems itself before it notifies the client of them.

Specified by:
setExceptionListener in interface javax.jms.Connection

start

public void start()
           throws javax.jms.JMSException
Starts (or restarts) a connection's delivery of incoming messages. A call to start on a connection that has already been started is ignored.

Specified by:
start in interface javax.jms.Connection

isStarted

protected boolean isStarted()

stop

public void stop()
          throws javax.jms.JMSException
Temporarily stops a connection's delivery of incoming messages. Delivery can be restarted using the connection's start method. When the connection is stopped, delivery to all the connection's message consumers is inhibited: synchronous receives block, and messages are not delivered to message listeners.

This call blocks until receives and/or message listeners in progress have completed.

Stopping a connection has no effect on its ability to send messages. A call to stop on a connection that has already been stopped is ignored.

A call to stop must not return until delivery of messages has paused. This means that a client can rely on the fact that none of its message listeners will be called and that all threads of control waiting for receive calls to return will not return with a message until the connection is restarted. The receive timers for a stopped connection continue to advance, so receives may time out while the connection is stopped.

If message listeners are running when stop is invoked, the stop call must wait until all of them have returned before it may return. While these message listeners are completing, they must have the full services of the connection available to them.

Specified by:
stop in interface javax.jms.Connection

close

public void close()
           throws javax.jms.JMSException
Closes the connection.

Since a provider typically allocates significant resources outside the JVM on behalf of a connection, clients should close these resources when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.

There is no need to close the sessions, producers, and consumers of a closed connection.

Closing a connection causes all temporary destinations to be deleted.

When this method is invoked, it should not return until message processing has been shut down in an orderly fashion. This means that all message listeners that may have been running have returned, and that all pending receives have returned. A close terminates all pending message receives on the connection's sessions' consumers. The receives may return with a message or with null, depending on whether there was a message available at the time of the close. If one or more of the connection's sessions' message listeners is processing a message at the time when connection close is invoked, all the facilities of the connection and its sessions must remain available to those listeners until they return control to the JMS provider.

Closing a connection causes any of its sessions' transactions in progress to be rolled back. In the case where a session's work is coordinated by an external transaction manager, a session's commit and rollback methods are not used and the result of a closed session's work is determined later by the transaction manager. Closing a connection does NOT force an acknowledgment of client-acknowledged sessions.

Invoking the acknowledge method of a received message from a closed connection's session must throw an IllegalStateException. Closing a closed connection must NOT throw an exception.

Specified by:
close in interface javax.jms.Connection

terminateBrokerVM

public void terminateBrokerVM()
                       throws javax.jms.JMSException
Tells the broker to terminate its VM. This can be used to cleanly terminate a broker running in a standalone java process. Server must have property enable.vm.shutdown=true defined to allow this to work.


checkClosed

protected void checkClosed()
                    throws javax.jms.JMSException
simply throws an exception if the Connection is already closed


createConnectionConsumer

public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination,
                                                             java.lang.String messageSelector,
                                                             javax.jms.ServerSessionPool sessionPool,
                                                             int maxMessages)
                                                      throws javax.jms.JMSException
Creates a connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.

Specified by:
createConnectionConsumer in interface javax.jms.Connection
Since:
1.1

createConnectionConsumer

public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination,
                                                             java.lang.String messageSelector,
                                                             javax.jms.ServerSessionPool sessionPool,
                                                             int maxMessages,
                                                             boolean noLocal)
                                                      throws javax.jms.JMSException
Creates a connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.

Since:
1.1

createDurableConnectionConsumer

public javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic,
                                                                    java.lang.String subscriptionName,
                                                                    java.lang.String messageSelector,
                                                                    javax.jms.ServerSessionPool sessionPool,
                                                                    int maxMessages)
                                                             throws javax.jms.JMSException
Create a durable connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.

Specified by:
createDurableConnectionConsumer in interface javax.jms.Connection
Since:
1.1

createDurableConnectionConsumer

public javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic,
                                                                    java.lang.String subscriptionName,
                                                                    java.lang.String messageSelector,
                                                                    javax.jms.ServerSessionPool sessionPool,
                                                                    int maxMessages,
                                                                    boolean noLocal)
                                                             throws javax.jms.JMSException
Create a durable connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.

Since:
1.1

consume

public void consume(org.activemq.message.Packet packet)
Implementation of the PacketListener interface - consume a packet

Specified by:
consume in interface org.activemq.message.PacketListener

assembleMessage

private final org.activemq.message.ActiveMQMessage assembleMessage(org.activemq.message.ActiveMQMessage message)

onException

public void onException(javax.jms.JMSException jmsEx)
Specified by:
onException in interface javax.jms.ExceptionListener

createTopicSession

public javax.jms.TopicSession createTopicSession(boolean transacted,
                                                 int acknowledgeMode)
                                          throws javax.jms.JMSException
Creates a TopicSession object.

Specified by:
createTopicSession in interface javax.jms.TopicConnection

createConnectionConsumer

public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Topic topic,
                                                             java.lang.String messageSelector,
                                                             javax.jms.ServerSessionPool sessionPool,
                                                             int maxMessages)
                                                      throws javax.jms.JMSException
Creates a connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.

Specified by:
createConnectionConsumer in interface javax.jms.TopicConnection

createQueueSession

public javax.jms.QueueSession createQueueSession(boolean transacted,
                                                 int acknowledgeMode)
                                          throws javax.jms.JMSException
Creates a QueueSession object.

Specified by:
createQueueSession in interface javax.jms.QueueConnection

createConnectionConsumer

public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Queue queue,
                                                             java.lang.String messageSelector,
                                                             javax.jms.ServerSessionPool sessionPool,
                                                             int maxMessages)
                                                      throws javax.jms.JMSException
Creates a connection consumer for this connection (optional operation). This is an expert facility not used by regular JMS clients.

Specified by:
createConnectionConsumer in interface javax.jms.QueueConnection

checkClientIDWasManuallySpecified

public void checkClientIDWasManuallySpecified()
                                       throws javax.jms.JMSException
Ensures that the clientID was manually specified and not auto-generated. If the clientID was not specified this method will throw an exception. This method is used to ensure that the clientID + durableSubscriber name are used correctly.


statusChanged

public void statusChanged(org.activemq.transport.TransportStatusEvent event)
handle disconnect/reconnect events

Specified by:
statusChanged in interface org.activemq.transport.TransportStatusEventListener

asyncSendPacket

public void asyncSendPacket(org.activemq.message.Packet packet)
                     throws javax.jms.JMSException
send a Packet through the Connection - for internal use only


asyncSendPacket

public void asyncSendPacket(org.activemq.message.Packet packet,
                            boolean doSendWhileReconnecting)
                     throws javax.jms.JMSException
send a Packet through the Connection - for internal use only


syncSendPacket

public void syncSendPacket(org.activemq.message.Packet packet)
                    throws javax.jms.JMSException
send a Packet through a Connection - for internal use only


syncSendPacket

public void syncSendPacket(org.activemq.message.Packet packet,
                           int timeout)
                    throws javax.jms.JMSException
Send a packet through a Connection - for internal use only


syncSendRequest

public org.activemq.message.Receipt syncSendRequest(org.activemq.message.Packet packet)
                                             throws javax.jms.JMSException

getPrefetchPolicy

public ActiveMQPrefetchPolicy getPrefetchPolicy()

setPrefetchPolicy

public void setPrefetchPolicy(ActiveMQPrefetchPolicy prefetchPolicy)

getSendCloseTimeout

public int getSendCloseTimeout()

setSendCloseTimeout

public void setSendCloseTimeout(int sendCloseTimeout)

getSendConnectionInfoTimeout

public int getSendConnectionInfoTimeout()

setSendConnectionInfoTimeout

public void setSendConnectionInfoTimeout(int sendConnectionInfoTimeout)

getTransportChannel

public org.activemq.transport.TransportChannel getTransportChannel()

getInitializedClientID

public java.lang.String getInitializedClientID()
                                        throws javax.jms.JMSException
Returns the clientID of the connection, forcing one to be generated if one has not yet been configured


addSession

protected void addSession(ActiveMQSession session)
                   throws javax.jms.JMSException
Used internally for adding Sessions to the Connection


removeSession

protected void removeSession(ActiveMQSession session)
                      throws javax.jms.JMSException
Used interanlly for removing Sessions from a Connection


createSessionInfo

private org.activemq.message.SessionInfo createSessionInfo(ActiveMQSession session)

addConnectionConsumer

protected void addConnectionConsumer(ActiveMQConnectionConsumer connectionConsumer)
                              throws javax.jms.JMSException
Add a ConnectionConsumer


removeConnectionConsumer

protected void removeConnectionConsumer(ActiveMQConnectionConsumer connectionConsumer)
Remove a ConnectionConsumer


addMessageDispatcher

protected void addMessageDispatcher(ActiveMQMessageDispatcher messageDispatch)
                             throws javax.jms.JMSException
Add a Message dispatcher to receive messages from the Broker


removeMessageDispatcher

protected void removeMessageDispatcher(ActiveMQMessageDispatcher messageDispatcher)
Remove a Message dispatcher


handleAsyncException

protected void handleAsyncException(javax.jms.JMSException jmsEx)
Used for handling async exceptions


sendConnectionInfoToBroker

protected void sendConnectionInfoToBroker()
                                   throws javax.jms.JMSException

sendConnectionInfoToBroker

protected void sendConnectionInfoToBroker(int timeout,
                                          boolean forceResend,
                                          boolean closing)
                                   throws javax.jms.JMSException
Send the ConnectionInfo to the Broker


setConnectionMemoryLimit

public void setConnectionMemoryLimit(int newMemoryLimit)
Set the maximum amount of memory this Connection should use for buffered inbound messages


getConnectionMemoryLimit

public int getConnectionMemoryLimit()
Get the current value for the maximum amount of memory this Connection should use for buffered inbound messages


capacityChanged

public void capacityChanged(org.activemq.capacity.CapacityMonitorEvent event)
CapacityMonitorEventListener implementation called when the capacity of a CapacityService changes

Specified by:
capacityChanged in interface org.activemq.capacity.CapacityMonitorEventListener

getNextConsumerNumber

protected int getNextConsumerNumber()

generateSessionId

protected short generateSessionId()

ensureClientIDInitialised

private void ensureClientIDInitialised()

getMemoryBoundedQueue

protected org.activemq.io.util.MemoryBoundedQueue getMemoryBoundedQueue(java.lang.String name)

doReconnect

protected void doReconnect()

isUseAsyncSend

public boolean isUseAsyncSend()

setUseAsyncSend

public void setUseAsyncSend(boolean useAsyncSend)

isCachingEnabled

public boolean isCachingEnabled()

setCachingEnabled

public void setCachingEnabled(boolean cachingEnabled)

isJ2EEcompliant

public boolean isJ2EEcompliant()

setJ2EEcompliant

public void setJ2EEcompliant(boolean ecompliant)

isInternalConnection

public boolean isInternalConnection()

setInternalConnection

public void setInternalConnection(boolean internalConnection)

isDoMessageCompression

public boolean isDoMessageCompression()

setDoMessageCompression

public void setDoMessageCompression(boolean doMessageCompression)

isDoMessageFragmentation

public boolean isDoMessageFragmentation()

setDoMessageFragmentation

public void setDoMessageFragmentation(boolean doMessageFragmentation)

getMessageCompressionLevel

public int getMessageCompressionLevel()

setMessageCompressionLevel

public void setMessageCompressionLevel(int messageCompressionLevel)

getMessageCompressionLimit

public int getMessageCompressionLimit()

setMessageCompressionLimit

public void setMessageCompressionLimit(int messageCompressionLimit)

getMessageCompressionStrategy

public int getMessageCompressionStrategy()

setMessageCompressionStrategy

public void setMessageCompressionStrategy(int messageCompressionStrategy)

getMessageFragmentationLimit

public int getMessageFragmentationLimit()

setMessageFragmentationLimit

public void setMessageFragmentationLimit(int messageFragmentationLimit)

isDisableTimeStampsByDefault

public boolean isDisableTimeStampsByDefault()

setDisableTimeStampsByDefault

public void setDisableTimeStampsByDefault(boolean disableTimeStampsByDefault)

isPrepareMessageBodyOnSend

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


setPrepareMessageBodyOnSend

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


isCopyMessageOnSend

public boolean isCopyMessageOnSend()

setCopyMessageOnSend

public void setCopyMessageOnSend(boolean copyMessageOnSend)

isQuickClose

public boolean isQuickClose()

setQuickClose

public void setQuickClose(boolean quickClose)

isOptimizedMessageDispatch

public boolean isOptimizedMessageDispatch()

setOptimizedMessageDispatch

public void setOptimizedMessageDispatch(boolean optimizedMessageDispatch)

clearMessagesInProgress

protected void clearMessagesInProgress()

destroyDestination

public void destroyDestination(org.activemq.message.ActiveMQDestination destination)
                        throws javax.jms.JMSException
Tells the broker to destroy a destination.


cleanup

public void cleanup()
             throws javax.jms.JMSException
Cleans up this connection so that it's state is as if the connection was just created. This allows the Resource Adapter to clean up a connection so that it can be reused without having to close and recreate the connection.


changeUserInfo

public void changeUserInfo(java.lang.String theUserName,
                           java.lang.String thePassword)
                    throws javax.jms.JMSException
Changes the associated username/password that is associated with this connection. If the connection has been used, you must called cleanup() before calling this method.


addToTransientConsumedRedeliverCache

protected void addToTransientConsumedRedeliverCache(org.activemq.message.ActiveMQMessage message)

replayTransientConsumedRedeliveredMessages

protected void replayTransientConsumedRedeliveredMessages(ActiveMQSession session,
                                                          ActiveMQMessageConsumer consumer)
                                                   throws javax.jms.JMSException

getFilterFactory

private org.activemq.filter.FilterFactory getFilterFactory()

startTemporaryDestination

protected void startTemporaryDestination(org.activemq.message.ActiveMQDestination dest)
                                  throws javax.jms.JMSException

stopTemporaryDestination

protected void stopTemporaryDestination(org.activemq.message.ActiveMQDestination dest)
                                 throws javax.jms.JMSException

closeTemporaryDestinations

protected void closeTemporaryDestinations()
                                   throws javax.jms.JMSException

startAdvisoryForTempDestination

protected void startAdvisoryForTempDestination(javax.jms.Destination d)
                                        throws javax.jms.JMSException

stopAdvisoryForTempDestination

protected void stopAdvisoryForTempDestination(org.activemq.message.ActiveMQDestination d)
                                       throws javax.jms.JMSException

validateDestination

protected final void validateDestination(org.activemq.message.ActiveMQDestination dest)
                                  throws javax.jms.JMSException

getResourceManagerId

public java.lang.String getResourceManagerId()
                                      throws javax.jms.JMSException

determineResourceManagerId

private java.lang.String determineResourceManagerId()
                                             throws javax.jms.JMSException
Get's the resource manager id.


getFragmentation

public org.activemq.io.util.ByteArrayFragmentation getFragmentation()

getAssemblies

public ConcurrentHashMap getAssemblies()