ActiveMQConnection (ActiveMQ 1.1 API)
Keywords: org.codehaus.activemq.ActiveMQConnection class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.activemq
Class ActiveMQConnection

    java.lang.Object
      org.codehaus.activemq.ActiveMQConnection

All Implemented Interfaces:
  CapacityMonitorEventListener, Connection, ExceptionListener, PacketListener, QueueConnection, StatsCapable, TopicConnection, TransportStatusEventListener

Direct Known Subclasses:
  ActiveMQXAConnection

public class ActiveMQConnection
extends Object
implements Connection, PacketListener, ExceptionListener, TopicConnection, QueueConnection, StatsCapable, CapacityMonitorEventListener, TransportStatusEventListener

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:

- It encapsulates an open connection with a JMS provider. It typically represents an open TCP/IP socket between a client and the service provider software.
- Its creation is where client authentication takes place.
- It can specify a unique client identifier.
- It provides a `ConnectionMetaData` object.
- It supports an optional `ExceptionListener` object.

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.72 $
See Also:
  `Connection`, `ConnectionFactory`, `QueueConnection`, `TopicConnection`, `TopicConnectionFactory`, `QueueConnection`, `QueueConnectionFactory`

Field Summary
`protected String` | `clientID`
`protected IdGenerator` | `consumerIdGenerator`
`static String` | `DEFAULT_PASSWORD` Default Password for the Connection
`static String` | `DEFAULT_URL` Default URL for the ActiveMQ Broker
`static String` | `DEFAULT_USER` Default UserName for the Connection
`protected IdGenerator` | `packetIdGenerator`
`protected boolean` | `useAsyncSend` Should we use an async send for persistent non transacted messages ?

Constructor Summary
`protected` | `ActiveMQConnection(ActiveMQConnectionFactory factory, String theUserName, String thePassword)`
`` | `ActiveMQConnection(ActiveMQConnectionFactory factory, String theUserName, String thePassword, 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
`void` | `asyncSendPacket(Packet packet)` send a Packet through the Connection - for internal use only
`void` | `asyncSendPacket(Packet packet, boolean doSendWhileReconnecting)` send a Packet through the Connection - for internal use only
`void` | `capacityChanged(CapacityMonitorEvent event)` CapacityMonitorEventListener implementation called when the capacity of a CapacityService changes
`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
`protected void` | `clearMessagesInProgress()`
`void` | `close()` Closes the connection.
`void` | `consume(Packet packet)` Implementation of the PacketListener interface - consume a packet
`ConnectionConsumer` | `createConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool sessionPool, int maxMessages)` Creates a connection consumer for this connection (optional operation).
`ConnectionConsumer` | `createConnectionConsumer(Queue queue, String messageSelector, ServerSessionPool sessionPool, int maxMessages)` Creates a connection consumer for this connection (optional operation).
`ConnectionConsumer` | `createConnectionConsumer(Topic topic, String messageSelector, ServerSessionPool sessionPool, int maxMessages)` Creates a connection consumer for this connection (optional operation).
`ConnectionConsumer` | `createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages)` Create a durable connection consumer for this connection (optional operation).
`QueueSession` | `createQueueSession(boolean transacted, int acknowledgeMode)` Creates a `QueueSession` object.
`Session` | `createSession(boolean transacted, int acknowledgeMode)` Creates a `Session` object.
`TopicSession` | `createTopicSession(boolean transacted, int acknowledgeMode)` Creates a `TopicSession` object.
`protected void` | `doReconnect()`
`protected void` | `ensureClientIDInitialised()`
`protected String` | `generateSessionId()`
`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
`JMSConnectionStatsImpl` | `getConnectionStats()`
`ExceptionListener` | `getExceptionListener()` Gets the `ExceptionListener` object for this connection.
`String` | `getInitializedClientID()` Returns the clientID of the connection, forcing one to be generated if one has not yet been configured
`protected MemoryBoundedQueue` | `getMemoryBoundedQueue(String name)`
`ConnectionMetaData` | `getMetaData()` Gets the metadata for this connection.
`protected int` | `getNextConsumerNumber()`
`ActiveMQPrefetchPolicy` | `getPrefetchPolicy()`
`int` | `getSendCloseTimeout()`
`int` | `getSendConnectionInfoTimeout()`
`Stats` | `getStats()`
`TransportChannel` | `getTransportChannel()`
`protected void` | `handleAsyncException(JMSException jmsEx)` Used for handling async exceptions
`protected boolean` | `isStarted()`
`boolean` | `isUseAsyncSend()`
`static ActiveMQConnection` | `makeConnection()` A static helper method to create a new connection
`static ActiveMQConnection` | `makeConnection(String uri)` A static helper method to create a new connection
`static ActiveMQConnection` | `makeConnection(String user, String password, String uri)` A static helper method to create a new connection
`void` | `onException(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` | `sendConnectionInfoToBroker()`
`protected void` | `sendConnectionInfoToBroker(int timeout, boolean isClosed)` Send the ConnectionInfo to the Broker
`void` | `setClientID(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` | `setExceptionListener(ExceptionListener listener)` Sets an exception listener for this connection.
`void` | `setPrefetchPolicy(ActiveMQPrefetchPolicy prefetchPolicy)`
`void` | `setSendCloseTimeout(int sendCloseTimeout)`
`void` | `setSendConnectionInfoTimeout(int sendConnectionInfoTimeout)`
`void` | `setUseAsyncSend(boolean useAsyncSend)`
`void` | `start()` Starts (or restarts) a connection's delivery of incoming messages.
`void` | `statusChanged(TransportStatusEvent event)` handle disconnect/reconnect events
`void` | `stop()` Temporarily stops a connection's delivery of incoming messages.
`void` | `syncSendPacket(Packet packet)` send a Packet through a Connection - for internal use only
`void` | `syncSendPacket(Packet packet, int timeout)` Send a packet through a Connection - for internal use only
`Receipt` | `syncSendRequest(Packet packet)`

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 String DEFAULT_USER

  Default UserName for the Connection

  See Also:
    Constant Field Values

### DEFAULT_URL

    public static final String DEFAULT_URL

  Default URL for the ActiveMQ Broker

  See Also:
    Constant Field Values

### DEFAULT_PASSWORD

    public static final String DEFAULT_PASSWORD

  Default Password for the Connection

  See Also:
    Constant Field Values

### clientID

    protected String clientID

### consumerIdGenerator

    protected IdGenerator consumerIdGenerator

### packetIdGenerator

    protected IdGenerator packetIdGenerator

### useAsyncSend

    protected boolean useAsyncSend

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

Constructor Detail

### ActiveMQConnection

    public ActiveMQConnection(ActiveMQConnectionFactory factory,
                              String theUserName,
                              String thePassword,
                              TransportChannel transportChannel)
                       throws JMSException

  Constructs a connection from an existing TransportChannel and user/password.

Parameters:
  `factory` -
  `theUserName` - the users name
  `thePassword` - the password
  `transportChannel` - the transport channel to communicate with the server
Throws:
  `JMSException`

### ActiveMQConnection

    protected ActiveMQConnection(ActiveMQConnectionFactory factory,
                                 String theUserName,
                                 String thePassword)

Method Detail

### makeConnection

    public static ActiveMQConnection makeConnection()
                                             throws JMSException

  A static helper method to create a new connection

  Returns:
    an ActiveMQConnection
  Throws:
    `JMSException`

### makeConnection

    public static ActiveMQConnection makeConnection(String uri)
                                             throws JMSException

  A static helper method to create a new connection

  Parameters:
    `uri` -
  Returns:
    and ActiveMQConnection
  Throws:
    `JMSException`

### makeConnection

    public static ActiveMQConnection makeConnection(String user,
                                                    String password,
                                                    String uri)
                                             throws JMSException

  A static helper method to create a new connection

  Parameters:
    `user` -
    `password` -
    `uri` -
  Returns:
    an ActiveMQConnection
  Throws:
    `JMSException`

### getStats

    public Stats getStats()

  Specified by:
    `getStats` in interface `StatsCapable`
  Returns:
    statistics for this Connection

### getConnectionStats

    public JMSConnectionStatsImpl getConnectionStats()

  Returns:
    a number unique for this connection

### createSession

    public Session createSession(boolean transacted,
                                 int acknowledgeMode)
                          throws JMSException

  Creates a `Session` object.

  Specified by:
    `createSession` in interface `Connection`
  Parameters:
    `transacted` - indicates whether the session is transacted
    `acknowledgeMode` - indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values are `Session.AUTO_ACKNOWLEDGE`, `Session.CLIENT_ACKNOWLEDGE`, and `Session.DUPS_OK_ACKNOWLEDGE`.
  Returns:
    a newly created session
  Throws:
    `JMSException` - if the `Connection` object fails to create a session due to some internal error or lack of support for the specific transaction and acknowledgement mode.
  Since:
    1.1
  See Also:
    `Session.AUTO_ACKNOWLEDGE`, `Session.CLIENT_ACKNOWLEDGE`, `Session.DUPS_OK_ACKNOWLEDGE`

### getClientID

    public String getClientID()
                       throws 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 `Connection`
  Returns:
    the unique client identifier
  Throws:
    `JMSException` - if the JMS provider fails to return the client ID for this connection due to some internal error.

### setClientID

    public void setClientID(String newClientID)
                     throws 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 `Connection`
  Parameters:
    `newClientID` - the unique client identifier
  Throws:
    `JMSException` - if the JMS provider fails to set the client ID for this connection due to some internal error.
    `InvalidClientIDException` - if the JMS client specifies an invalid or duplicate client ID.
    `IllegalStateException` - if the JMS client attempts to set a connection's client ID at the wrong time or when it has been administratively configured.

### getMetaData

    public ConnectionMetaData getMetaData()
                                   throws JMSException

  Gets the metadata for this connection.

  Specified by:
    `getMetaData` in interface `Connection`
  Returns:
    the connection metadata
  Throws:
    `JMSException` - if the JMS provider fails to get the connection metadata for this connection.
  See Also:
    `ConnectionMetaData`

### getExceptionListener

    public ExceptionListener getExceptionListener()
                                           throws JMSException

  Gets the `ExceptionListener` object for this connection. Not every `Connection` has an `ExceptionListener` associated with it.

  Specified by:
    `getExceptionListener` in interface `Connection`
  Returns:
    the `ExceptionListener` for this connection, or null. if no `ExceptionListener` is associated with this connection.
  Throws:
    `JMSException` - if the JMS provider fails to get the `ExceptionListener` for this connection.
  See Also:
    `Connection.setExceptionListener(ExceptionListener)`

### setExceptionListener

    public void setExceptionListener(ExceptionListener listener)
                              throws 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 `Connection`
  Parameters:
    `listener` - the exception listener
  Throws:
    `JMSException` - if the JMS provider fails to set the exception listener for this connection.

### start

    public void start()
               throws 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 `Connection`
  Throws:
    `JMSException` - if the JMS provider fails to start message delivery due to some internal error.
  See Also:
    `Connection.stop()`

### isStarted

    protected boolean isStarted()

  Returns:
    true if this Connection is started

### stop

    public void stop()
              throws 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 `Connection`
  Throws:
    `JMSException` - if the JMS provider fails to stop message delivery due to some internal error.
  See Also:
    `Connection.start()`

### close

    public void close()
               throws 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 `Connection`
  Throws:
    `JMSException` - if the JMS provider fails to close the connection due to some internal error. For example, a failure to release resources or to close a socket connection can cause this exception to be thrown.

### checkClosed

    protected void checkClosed()
                        throws JMSException

  simply throws an exception if the Connection is already closed

  Throws:
    `JMSException`

### createConnectionConsumer

    public ConnectionConsumer createConnectionConsumer(Destination destination,
                                                       String messageSelector,
                                                       ServerSessionPool sessionPool,
                                                       int maxMessages)
                                                throws 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 `Connection`
  Parameters:
    `destination` - the destination to access
    `messageSelector` - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
    `sessionPool` - the server session pool to associate with this connection consumer
    `maxMessages` - the maximum number of messages that can be assigned to a server session at one time
  Returns:
    the connection consumer
  Throws:
    `JMSException` - if the `Connection` object fails to create a connection consumer due to some internal error or invalid arguments for `sessionPool` and `messageSelector`.
    `InvalidDestinationException` - if an invalid destination is specified.
    `InvalidSelectorException` - if the message selector is invalid.
  Since:
    1.1
  See Also:
    `ConnectionConsumer`

### createDurableConnectionConsumer

    public ConnectionConsumer createDurableConnectionConsumer(Topic topic,
                                                              String subscriptionName,
                                                              String messageSelector,
                                                              ServerSessionPool sessionPool,
                                                              int maxMessages)
                                                       throws 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 `Connection`
  Parameters:
    `topic` - topic to access
    `subscriptionName` - durable subscription name
    `messageSelector` - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
    `sessionPool` - the server session pool to associate with this durable connection consumer
    `maxMessages` - the maximum number of messages that can be assigned to a server session at one time
  Returns:
    the durable connection consumer
  Throws:
    `JMSException` - if the `Connection` object fails to create a connection consumer due to some internal error or invalid arguments for `sessionPool` and `messageSelector`.
    `InvalidDestinationException` - if an invalid destination is specified.
    `InvalidSelectorException` - if the message selector is invalid.
  Since:
    1.1
  See Also:
    `ConnectionConsumer`

### consume

    public void consume(Packet packet)

  Implementation of the PacketListener interface - consume a packet

  Specified by:
    `consume` in interface `PacketListener`
  Parameters:
    `packet` - - the Packet to consume
  See Also:
    `PacketListener.consume(org.codehaus.activemq.message.Packet)`

### onException

    public void onException(JMSException jmsEx)

  Specified by:
    `onException` in interface `ExceptionListener`
  See Also:
    `ExceptionListener.onException(javax.jms.JMSException)`

### createTopicSession

    public TopicSession createTopicSession(boolean transacted,
                                           int acknowledgeMode)
                                    throws JMSException

  Creates a `TopicSession` object.

  Specified by:
    `createTopicSession` in interface `TopicConnection`
  Parameters:
    `transacted` - indicates whether the session is transacted
    `acknowledgeMode` - indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values are `Session.AUTO_ACKNOWLEDGE`, `Session.CLIENT_ACKNOWLEDGE`, and `Session.DUPS_OK_ACKNOWLEDGE`.
  Returns:
    a newly created topic session
  Throws:
    `JMSException` - if the `TopicConnection` object fails to create a session due to some internal error or lack of support for the specific transaction and acknowledgement mode.
  See Also:
    `Session.AUTO_ACKNOWLEDGE`, `Session.CLIENT_ACKNOWLEDGE`, `Session.DUPS_OK_ACKNOWLEDGE`

### createConnectionConsumer

    public ConnectionConsumer createConnectionConsumer(Topic topic,
                                                       String messageSelector,
                                                       ServerSessionPool sessionPool,
                                                       int maxMessages)
                                                throws 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 `TopicConnection`
  Parameters:
    `topic` - the topic to access
    `messageSelector` - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
    `sessionPool` - the server session pool to associate with this connection consumer
    `maxMessages` - the maximum number of messages that can be assigned to a server session at one time
  Returns:
    the connection consumer
  Throws:
    `JMSException` - if the `TopicConnection` object fails to create a connection consumer due to some internal error or invalid arguments for `sessionPool` and `messageSelector`.
    `InvalidDestinationException` - if an invalid topic is specified.
    `InvalidSelectorException` - if the message selector is invalid.
  See Also:
    `ConnectionConsumer`

### createQueueSession

    public QueueSession createQueueSession(boolean transacted,
                                           int acknowledgeMode)
                                    throws JMSException

  Creates a `QueueSession` object.

  Specified by:
    `createQueueSession` in interface `QueueConnection`
  Parameters:
    `transacted` - indicates whether the session is transacted
    `acknowledgeMode` - indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values are `Session.AUTO_ACKNOWLEDGE`, `Session.CLIENT_ACKNOWLEDGE`, and `Session.DUPS_OK_ACKNOWLEDGE`.
  Returns:
    a newly created queue session
  Throws:
    `JMSException` - if the `QueueConnection` object fails to create a session due to some internal error or lack of support for the specific transaction and acknowledgement mode.
  See Also:
    `Session.AUTO_ACKNOWLEDGE`, `Session.CLIENT_ACKNOWLEDGE`, `Session.DUPS_OK_ACKNOWLEDGE`

### createConnectionConsumer

    public ConnectionConsumer createConnectionConsumer(Queue queue,
                                                       String messageSelector,
                                                       ServerSessionPool sessionPool,
                                                       int maxMessages)
                                                throws 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 `QueueConnection`
  Parameters:
    `queue` - the queue to access
    `messageSelector` - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
    `sessionPool` - the server session pool to associate with this connection consumer
    `maxMessages` - the maximum number of messages that can be assigned to a server session at one time
  Returns:
    the connection consumer
  Throws:
    `JMSException` - if the `QueueConnection` object fails to create a connection consumer due to some internal error or invalid arguments for `sessionPool` and `messageSelector`.
    `InvalidDestinationException` - if an invalid queue is specified.
    `InvalidSelectorException` - if the message selector is invalid.
  See Also:
    `ConnectionConsumer`

### checkClientIDWasManuallySpecified

    public void checkClientIDWasManuallySpecified()
                                           throws 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.

  Throws:
    `JMSException`

### statusChanged

    public void statusChanged(TransportStatusEvent event)

  handle disconnect/reconnect events

  Specified by:
    `statusChanged` in interface `TransportStatusEventListener`
  Parameters:
    `event` -

### asyncSendPacket

    public void asyncSendPacket(Packet packet)
                         throws JMSException

  send a Packet through the Connection - for internal use only

  Parameters:
    `packet` -
  Throws:
    `JMSException`

### asyncSendPacket

    public void asyncSendPacket(Packet packet,
                                boolean doSendWhileReconnecting)
                         throws JMSException

  send a Packet through the Connection - for internal use only

  Parameters:
    `packet` -
    `doSendWhileReconnecting` -
  Throws:
    `JMSException`

### syncSendPacket

    public void syncSendPacket(Packet packet)
                        throws JMSException

  send a Packet through a Connection - for internal use only

  Parameters:
    `packet` -
  Throws:
    `JMSException`

### syncSendPacket

    public void syncSendPacket(Packet packet,
                               int timeout)
                        throws JMSException

  Send a packet through a Connection - for internal use only

  Parameters:
    `packet` -
    `timeout` -
  Throws:
    `JMSException`

### getPrefetchPolicy

    public ActiveMQPrefetchPolicy getPrefetchPolicy()

  Returns:
    Returns the prefetchPolicy.

### setPrefetchPolicy

    public void setPrefetchPolicy(ActiveMQPrefetchPolicy prefetchPolicy)

  Parameters:
    `prefetchPolicy` - The prefetchPolicy to set.

### getSendCloseTimeout

    public int getSendCloseTimeout()

### setSendCloseTimeout

    public void setSendCloseTimeout(int sendCloseTimeout)

### getSendConnectionInfoTimeout

    public int getSendConnectionInfoTimeout()

### setSendConnectionInfoTimeout

    public void setSendConnectionInfoTimeout(int sendConnectionInfoTimeout)

### syncSendRequest

    public Receipt syncSendRequest(Packet packet)
                            throws JMSException

  Throws:
    `JMSException`

### getTransportChannel

    public TransportChannel getTransportChannel()

### getInitializedClientID

    public String getInitializedClientID()
                                  throws JMSException

  Returns the clientID of the connection, forcing one to be generated if one has not yet been configured

  Throws:
    `JMSException`

### addSession

    protected void addSession(ActiveMQSession session)
                       throws JMSException

  Used internally for adding Sessions to the Connection

  Parameters:
    `session` -
  Throws:
    `JMSException`

### removeSession

    protected void removeSession(ActiveMQSession session)
                          throws JMSException

  Used interanlly for removing Sessions from a Connection

  Parameters:
    `session` -
  Throws:
    `JMSException`

### addConnectionConsumer

    protected void addConnectionConsumer(ActiveMQConnectionConsumer connectionConsumer)
                                  throws JMSException

  Add a ConnectionConsumer

  Parameters:
    `connectionConsumer` -
  Throws:
    `JMSException`

### removeConnectionConsumer

    protected void removeConnectionConsumer(ActiveMQConnectionConsumer connectionConsumer)

  Remove a ConnectionConsumer

  Parameters:
    `connectionConsumer` -

### addMessageDispatcher

    protected void addMessageDispatcher(ActiveMQMessageDispatcher messageDispatch)
                                 throws JMSException

  Add a Message dispatcher to receive messages from the Broker

  Parameters:
    `messageDispatch` -
  Throws:
    `JMSException` - if an internal error

### removeMessageDispatcher

    protected void removeMessageDispatcher(ActiveMQMessageDispatcher messageDispatcher)

  Remove a Message dispatcher

  Parameters:
    `messageDispatcher` -

### handleAsyncException

    protected void handleAsyncException(JMSException jmsEx)

  Used for handling async exceptions

  Parameters:
    `jmsEx` -

### sendConnectionInfoToBroker

    protected void sendConnectionInfoToBroker()
                                       throws JMSException

  Throws:
    `JMSException`

### sendConnectionInfoToBroker

    protected void sendConnectionInfoToBroker(int timeout,
                                              boolean isClosed)
                                       throws JMSException

  Send the ConnectionInfo to the Broker

  Parameters:
    `timeout` -
    `isClosed` -
  Throws:
    `JMSException`

### setConnectionMemoryLimit

    public void setConnectionMemoryLimit(int newMemoryLimit)

  Set the maximum amount of memory this Connection should use for buffered inbound messages

  Parameters:
    `newMemoryLimit` - the new memory limit in bytes

### getConnectionMemoryLimit

    public int getConnectionMemoryLimit()

  Get the current value for the maximum amount of memory this Connection should use for buffered inbound messages

  Returns:
    the current limit in bytes

### capacityChanged

    public void capacityChanged(CapacityMonitorEvent event)

  CapacityMonitorEventListener implementation called when the capacity of a CapacityService changes

  Specified by:
    `capacityChanged` in interface `CapacityMonitorEventListener`
  Parameters:
    `event` -

### getNextConsumerNumber

    protected int getNextConsumerNumber()

  Returns:
    a number unique for this connection

### generateSessionId

    protected String generateSessionId()

### ensureClientIDInitialised

    protected void ensureClientIDInitialised()

### getMemoryBoundedQueue

    protected MemoryBoundedQueue getMemoryBoundedQueue(String name)

### doReconnect

    protected void doReconnect()

### isUseAsyncSend

    public boolean isUseAsyncSend()

  Returns:
    Returns the useAsyncSend.

### setUseAsyncSend

    public void setUseAsyncSend(boolean useAsyncSend)

  Parameters:
    `useAsyncSend` - The useAsyncSend to set.

### clearMessagesInProgress

    protected void clearMessagesInProgress()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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