org.objectweb.joram.client.jms
Class Connection

java.lang.Object
  extended by org.objectweb.joram.client.jms.Connection
All Implemented Interfaces:
javax.jms.Connection
Direct Known Subclasses:
QueueConnection, TopicConnection, XAConnection

public class Connection
extends java.lang.Object
implements javax.jms.Connection

Implements the javax.jms.Connection interface.

A Connection object allows the client's active connection to the Joram server. Connections support concurrent use, it serves several purposes:

A Joram 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. In order to minimize any client confusion that may result from asynchronous message delivery during setup, it is typical to leave the connection in stopped mode until setup is complete. A message producer can send messages while a connection is stopped.


Nested Class Summary
(package private)  class Connection.AtomicCounter
           
(package private)  class Connection.Closer
          This class synchronizes the close.
private static class Connection.Status
          Status of the connection.
 
Field Summary
private  java.util.Vector cconsumers
          Vector of the connection's consumers.
private  Connection.Closer closer
          Used to synchronize the method close()
private  FactoryParameters factoryParameters
          The factory's parameters.
private  int hashCode
           
private  int key
          Connection key.
static org.objectweb.util.monolog.api.Logger logger
           
private  Connection.AtomicCounter messagesC
          Messages counter.
private  ConnectionMetaData metaData
          Connection meta data.
private  RequestMultiplexer mtpx
          The request multiplexer used to communicate with the user proxy.
private  java.lang.String proxyId
          Client's agent proxy identifier.
private  Requestor requestor
          The requestor used to communicate with the user proxy.
private  java.util.Vector sessions
          Vector of the connection's sessions.
private  Connection.AtomicCounter sessionsC
          Sessions counter.
private  int status
          Status of the connection.
private  java.lang.String stringImage
           
private  Connection.AtomicCounter subsC
          Subscriptions counter.
 
Constructor Summary
Connection(FactoryParameters factoryParameters, RequestChannel requestChannel)
          Creates a Connection instance.
 
Method Summary
protected  void addSession(Session session)
          Called here and by sub-classes.
protected  void checkClosed()
          Checks if the connection is closed.
(package private)  void checkConsumers(java.lang.String agentId)
          Called by temporary destinations deletion.
 void cleanup()
          Used by OutboundConnection in the connector layer.
 void close()
          API method for closing the connection; even if the connection appears to be broken, closes the sessions.
(package private)  void closeConnectionConsumer(MultiSessionConsumer cc)
          Called by MultiSessionConsumer.
(package private)  void closeSession(Session session)
          Called by Session.
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination dest, java.lang.String selector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
          API method.
private  javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination dest, java.lang.String subName, java.lang.String selector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
           
 javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic, java.lang.String subName, java.lang.String selector, javax.jms.ServerSessionPool sessPool, int maxMessages)
          API method.
 javax.jms.Session createSession(boolean transacted, int acknowledgeMode)
          API method.
(package private)  void doClose()
           
 boolean equals(java.lang.Object obj)
          Returns true if the parameter is a Connection instance sharing the same proxy identifier and connection key.
 boolean getAsyncSend()
          Indicates whether the messages produced are asynchronously sent or not (without or with acknowledgement).
 java.lang.String getClientID()
          API method.
 javax.jms.ExceptionListener getExceptionListener()
          API method.
 boolean getImplicitAck()
          Indicates whether the messages consumed are implicitly acknowledged or not.
 java.util.List getInInterceptors()
          returns the list of IN message interceptors.
 javax.jms.ConnectionMetaData getMetaData()
          API method.
 java.util.List getOutInterceptors()
          returns the list of OUT message interceptors.
 java.lang.String getOutLocalAddress()
          Returns the local IP address on which the TCP connection is activated.
 int getOutLocalPort()
          Returns the local IP address port on which the TCP connection is activated This attribute is inherited from FactoryParameters.
 int getQueueMessageReadMax()
          Get the maximum number of messages that can be read at once from a queue for this Connection.
protected  RequestMultiplexer getRequestMultiplexer()
           
 int getTopicAckBufferMax()
          Get the maximum number of acknowledgements that can be buffered when using Session.DUPS_OK_ACKNOWLEDGE mode for this Connection.
 int getTopicActivationThreshold()
          Get the threshold of activation for this Connection.
 int getTopicPassivationThreshold()
          Get the threshold of passivation for this Connection.
 long getTxPendingTimer()
          Returns the duration in seconds during which a JMS transacted (non XA) session might be pending; above that duration the session is rolled back and closed; the 0 value means "no timer".
 int hashCode()
           
(package private)  boolean isStopped()
           
(package private)  java.lang.String nextMessageId()
          Returns a new message identifier.
(package private)  java.lang.String nextSessionId()
          Returns a new session identifier.
(package private)  java.lang.String nextSubName()
          Returns a new subscription name.
 void setClientID(java.lang.String clientID)
          API method.
 void setExceptionListener(javax.jms.ExceptionListener listener)
          API method.
private  void setStatus(int status)
           
 void start()
          API method for starting the connection.
 void stop()
          API method for stopping the connection; even if the connection appears to be broken, stops the sessions.
(package private)  AbstractJmsReply syncRequest(AbstractJmsRequest request)
           
 java.lang.String toString()
          String image of the connection.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

public static org.objectweb.util.monolog.api.Logger logger

mtpx

private RequestMultiplexer mtpx
The request multiplexer used to communicate with the user proxy.


requestor

private Requestor requestor
The requestor used to communicate with the user proxy.


metaData

private ConnectionMetaData metaData
Connection meta data.


sessionsC

private Connection.AtomicCounter sessionsC
Sessions counter.


messagesC

private Connection.AtomicCounter messagesC
Messages counter.


subsC

private Connection.AtomicCounter subsC
Subscriptions counter.


proxyId

private java.lang.String proxyId
Client's agent proxy identifier.


key

private int key
Connection key.


factoryParameters

private FactoryParameters factoryParameters
The factory's parameters.


status

private int status
Status of the connection. STOP, START, CLOSE


sessions

private java.util.Vector sessions
Vector of the connection's sessions.


cconsumers

private java.util.Vector cconsumers
Vector of the connection's consumers.


closer

private Connection.Closer closer
Used to synchronize the method close()


stringImage

private java.lang.String stringImage

hashCode

private int hashCode
Constructor Detail

Connection

public Connection(FactoryParameters factoryParameters,
                  RequestChannel requestChannel)
           throws javax.jms.JMSException
Creates a Connection instance.

Parameters:
factoryParameters - The factory parameters.
requestChannel - The actual connection to wrap.
Throws:
javax.jms.JMSSecurityException - If the user identification is incorrect.
javax.jms.IllegalStateException - If the server is not listening.
javax.jms.JMSException
Method Detail

setStatus

private void setStatus(int status)

isStopped

boolean isStopped()

toString

public java.lang.String toString()
String image of the connection.

Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Returns true if the parameter is a Connection instance sharing the same proxy identifier and connection key.

Overrides:
equals in class java.lang.Object

getTxPendingTimer

public final long getTxPendingTimer()
Returns the duration in seconds during which a JMS transacted (non XA) session might be pending; above that duration the session is rolled back and closed; the 0 value means "no timer".

Returns:
the duration in seconds during which a JMS transacted (non XA) session might be pending.
See Also:
FactoryParameters.txPendingTimer

getImplicitAck

public final boolean getImplicitAck()
Indicates whether the messages consumed are implicitly acknowledged or not. If true messages are immediately removed from queue when delivered and there is none acknowledge message from client to server.

This attribute is inherited from FactoryParameters, by default false.

Returns:
true if messages produced are implicitly acknowledged.
See Also:
FactoryParameters.implicitAck, Session.isImplicitAck()

getAsyncSend

public final boolean getAsyncSend()
Indicates whether the messages produced are asynchronously sent or not (without or with acknowledgement).

This attribute is inherited from FactoryParameters, by default false.

Returns:
true if messages produced are asynchronously sent.
See Also:
FactoryParameters.asyncSend, Session.isAsyncSend()

getQueueMessageReadMax

public final int getQueueMessageReadMax()
Get the maximum number of messages that can be read at once from a queue for this Connection.

This attribute is inherited from FactoryParameters, default value is 1.

Returns:
The maximum number of messages that can be read at once from a queue.
See Also:
FactoryParameters.queueMessageReadMax, Session.getQueueMessageReadMax()

getTopicAckBufferMax

public final int getTopicAckBufferMax()
Get the maximum number of acknowledgements that can be buffered when using Session.DUPS_OK_ACKNOWLEDGE mode for this Connection.

This attribute is inherited from FactoryParameters, default value is 0.

Returns:
The Maximum number of acknowledgements that can be buffered when using Session.DUPS_OK_ACKNOWLEDGE mode.
See Also:
FactoryParameters.topicAckBufferMax, Session.getTopicAckBufferMax()

getTopicPassivationThreshold

public final int getTopicPassivationThreshold()
Get the threshold of passivation for this Connection.

This threshold is the maximum messages number over which the subscription is passivated.

This attribute is inherited from FactoryParameters, default value is Integer.MAX_VALUE.

Returns:
The maximum messages number over which the subscription is passivated.
See Also:
FactoryParameters.topicPassivationThreshold, Session.getTopicPassivationThreshold()

getTopicActivationThreshold

public final int getTopicActivationThreshold()
Get the threshold of activation for this Connection.

This threshold is the minimum messages number below which the subscription is activated.

This attribute is inherited from FactoryParameters, default value is 0.

Returns:
The minimum messages number below which the subscription is activated.
See Also:
FactoryParameters.topicActivationThreshold, Session.getTopicActivationThreshold()

getOutLocalAddress

public final java.lang.String getOutLocalAddress()
Returns the local IP address on which the TCP connection is activated.

This attribute is inherited from FactoryParameters.

Returns:
the local IP address on which the TCP connection is activated.
See Also:
FactoryParameters.outLocalAddress

getOutLocalPort

public final int getOutLocalPort()
Returns the local IP address port on which the TCP connection is activated

This attribute is inherited from FactoryParameters.

Returns:
the local IP address port on which the TCP connection is activated.
See Also:
FactoryParameters.outLocalPort

getInInterceptors

public final java.util.List getInInterceptors()
returns the list of IN message interceptors.
Each IN message interceptor is called when receiving a message.
The execution follows the order of the elements within the list.

Returns:
the list of the IN message interceptors.

getOutInterceptors

public final java.util.List getOutInterceptors()
returns the list of OUT message interceptors.
Each OUT message interceptor is called when sending a message.
The execution follows the order of the elements within the list.

Returns:
the list of the OUT message interceptors.

checkClosed

protected final void checkClosed()
                          throws javax.jms.IllegalStateException
Checks if the connection is closed. If true raises an IllegalStateException.

Throws:
javax.jms.IllegalStateException

createConnectionConsumer

public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination dest,
                                                             java.lang.String selector,
                                                             javax.jms.ServerSessionPool sessionPool,
                                                             int maxMessages)
                                                      throws javax.jms.JMSException
API method.

Specified by:
createConnectionConsumer in interface javax.jms.Connection
Throws:
javax.jms.IllegalStateException - If the connection is closed.
javax.jms.InvalidSelectorException - If the selector syntax is wrong.
javax.jms.InvalidDestinationException - If the target destination does not exist.
javax.jms.JMSException - If the method fails for any other reason.

createDurableConnectionConsumer

public javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic,
                                                                    java.lang.String subName,
                                                                    java.lang.String selector,
                                                                    javax.jms.ServerSessionPool sessPool,
                                                                    int maxMessages)
                                                             throws javax.jms.JMSException
API method.

Specified by:
createDurableConnectionConsumer in interface javax.jms.Connection
Throws:
javax.jms.IllegalStateException - If the connection is closed.
javax.jms.InvalidSelectorException - If the selector syntax is wrong.
javax.jms.InvalidDestinationException - If the target topic does not exist.
javax.jms.JMSException - If the method fails for any other reason.

createConnectionConsumer

private javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination dest,
                                                              java.lang.String subName,
                                                              java.lang.String selector,
                                                              javax.jms.ServerSessionPool sessionPool,
                                                              int maxMessages)
                                                       throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createSession

public javax.jms.Session createSession(boolean transacted,
                                       int acknowledgeMode)
                                throws javax.jms.JMSException
API method.

Specified by:
createSession in interface javax.jms.Connection
Throws:
javax.jms.IllegalStateException - If the connection is closed.
javax.jms.JMSException - In case of an invalid acknowledge mode.

addSession

protected void addSession(Session session)
Called here and by sub-classes.


setExceptionListener

public void setExceptionListener(javax.jms.ExceptionListener listener)
                          throws javax.jms.JMSException
API method.

Specified by:
setExceptionListener in interface javax.jms.Connection
Throws:
javax.jms.IllegalStateException - If the connection is closed.
javax.jms.JMSException

getExceptionListener

public javax.jms.ExceptionListener getExceptionListener()
                                                 throws javax.jms.JMSException
API method.

Specified by:
getExceptionListener in interface javax.jms.Connection
Throws:
javax.jms.IllegalStateException - If the connection is closed.
javax.jms.JMSException

setClientID

public void setClientID(java.lang.String clientID)
                 throws javax.jms.JMSException
API method.

Specified by:
setClientID in interface javax.jms.Connection
Throws:
javax.jms.IllegalStateException - Systematically thrown.
javax.jms.JMSException

getClientID

public java.lang.String getClientID()
                             throws javax.jms.JMSException
API method.

Specified by:
getClientID in interface javax.jms.Connection
Throws:
javax.jms.IllegalStateException - If the connection is closed.
javax.jms.JMSException

getMetaData

public javax.jms.ConnectionMetaData getMetaData()
                                         throws javax.jms.JMSException
API method.

Specified by:
getMetaData in interface javax.jms.Connection
Throws:
javax.jms.IllegalStateException - If the connection is closed.
javax.jms.JMSException

start

public void start()
           throws javax.jms.JMSException
API method for starting the connection.

Specified by:
start in interface javax.jms.Connection
Throws:
javax.jms.IllegalStateException - If the connection is closed or broken.
javax.jms.JMSException

stop

public void stop()
          throws javax.jms.JMSException
API method for stopping the connection; even if the connection appears to be broken, stops the sessions.

Specified by:
stop in interface javax.jms.Connection
Throws:
javax.jms.IllegalStateException - If the connection is closed or broken.
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
API method for closing the connection; even if the connection appears to be broken, closes the sessions.

Specified by:
close in interface javax.jms.Connection
Throws:
javax.jms.JMSException - Actually never thrown.

doClose

void doClose()

cleanup

public void cleanup()
Used by OutboundConnection in the connector layer. When a connection is put back in a pool, it must be cleaned up.


nextSessionId

java.lang.String nextSessionId()
Returns a new session identifier.


nextMessageId

java.lang.String nextMessageId()
Returns a new message identifier.


nextSubName

java.lang.String nextSubName()
Returns a new subscription name.


closeSession

void closeSession(Session session)
Called by Session.


closeConnectionConsumer

void closeConnectionConsumer(MultiSessionConsumer cc)
Called by MultiSessionConsumer. Synchronized with run().


syncRequest

AbstractJmsReply syncRequest(AbstractJmsRequest request)
                       throws javax.jms.JMSException
Throws:
javax.jms.JMSException

checkConsumers

void checkConsumers(java.lang.String agentId)
              throws javax.jms.JMSException
Called by temporary destinations deletion.

Throws:
javax.jms.JMSException

getRequestMultiplexer

protected final RequestMultiplexer getRequestMultiplexer()


Copyright © 2010 ScalAgent D.T.. All Rights Reserved.