public class Connection extends Object implements Connection, ConnectionMBean
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:
Modifier and Type | Class and Description |
---|---|
(package private) class |
Connection.AtomicCounter |
(package private) class |
Connection.Closer
This class synchronizes the close.
|
private static class |
Connection.Status
Status of the connection.
|
Modifier and Type | Field and Description |
---|---|
private Vector |
cconsumers
Vector of the connection's consumers.
|
private String |
clientID
Client's identifier.
|
private Connection.Closer |
closer
Used to synchronize the method close()
|
private FactoryParameters |
factoryParameters
The factory's parameters.
|
private int |
hashCode |
private Identity |
identity |
protected String |
JMXBeanBaseName |
private int |
key
Connection key.
|
private boolean |
lockClientID |
static org.objectweb.util.monolog.api.Logger |
logger |
(package private) Map<String,Integer> |
messageConsumers |
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 String |
proxyId
Client's agent proxy identifier.
|
private Requestor |
requestor
The requestor used to communicate
with the user proxy.
|
private Vector |
sessions
Vector of the connection's sessions.
|
private Connection.AtomicCounter |
sessionsC
Sessions counter.
|
private int |
status
Status of the connection.
|
private String |
stringImage |
private Connection.AtomicCounter |
subsC
Subscriptions counter.
|
Constructor and Description |
---|
Connection()
Creates a
Connection instance. |
Modifier and Type | Method and Description |
---|---|
private void |
addClientIDToProxy(String clientID) |
protected void |
addSession(Session session)
Called here and by sub-classes.
|
(package private) boolean |
checkCLMessageProducer(Session session,
MessageProducer mp) |
protected void |
checkClosed()
Checks if the connection is closed.
|
(package private) boolean |
checkCLSession(Session session) |
(package private) void |
checkConsumers(String agentId)
Called by temporary destinations deletion.
|
(package private) boolean |
checkThread() |
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) boolean |
closeMessageConsumer(String targetName) |
(package private) void |
closeSession(Session session)
Called by Session.
|
ConnectionConsumer |
createConnectionConsumer(Destination dest,
String selector,
ServerSessionPool sessionPool,
int maxMessages)
API method.
|
private ConnectionConsumer |
createConnectionConsumer(Destination dest,
String subName,
String selector,
ServerSessionPool sessionPool,
int maxMessages) |
ConnectionConsumer |
createDurableConnectionConsumer(Topic topic,
String subName,
String selector,
ServerSessionPool sessionPool,
int maxMessages)
API method.
|
Session |
createSession()
Creates a session using JMS 2.O specification
In a Java SE environment or in the Java EE application client container:
The session will be non-transacted and received messages will be acknowledged automatically
using an acknowledgement mode of
Session.AUTO_ACKNOWLEDGE
For a definition of the meaning of this acknowledgement mode see the link below. |
Session |
createSession(boolean transacted,
int acknowledgeMode)
API method.
|
Session |
createSession(int sessionMode)
Creates a session using JMS 2.O specification
|
ConnectionConsumer |
createSharedConnectionConsumer(Topic topic,
String subscriptionName,
String messageSelector,
ServerSessionPool sessionPool,
int maxMessages) |
ConnectionConsumer |
createSharedDurableConnectionConsumer(Topic topic,
String subscriptionName,
String messageSelector,
ServerSessionPool sessionPool,
int maxMessages) |
(package private) void |
doClose() |
boolean |
equals(Object obj)
Returns
true if the parameter is a Connection instance
sharing the same proxy identifier and connection key. |
boolean |
getAsyncSend()
Indicates whether the persistent produced messages are asynchronously sent
(without acknowledge) or not.
|
String |
getClientID()
API method.
|
int |
getCompressedMinSize()
Returns the minimum size beyond which the message body is compressed.
|
int |
getCompressionLevel()
Get the compression level (0..9) for this Connection, this attribute is inherited from FactoryParameters.
|
ExceptionListener |
getExceptionListener()
API method.
|
boolean |
getImplicitAck()
Indicates whether the messages consumed are implicitly acknowledged
or not.
|
(package private) List |
getInInterceptors()
returns the list of IN message interceptors.
|
String |
getJMXBeanName() |
ConnectionMetaData |
getMetaData()
API method.
|
(package private) List |
getOutInterceptors()
returns the list of OUT message interceptors.
|
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 |
isOpenMessageConsumer(String targetName) |
boolean |
isStopped() |
void |
lockClientId() |
(package private) String |
nextMessageId()
Returns a new message identifier.
|
(package private) String |
nextSessionId()
Returns a new session identifier.
|
(package private) String |
nextSubName()
Returns a new subscription name.
|
void |
open(FactoryParameters factoryParameters,
RequestChannel requestChannel)
Open the
Connection . |
(package private) void |
openMessageConsumer(String targetName) |
String |
registerMBean(String base) |
void |
setClientID(String clientID)
API method.
|
void |
setExceptionListener(ExceptionListener listener)
API method.
|
void |
setJMXBeanBaseName(String JMXBeanBaseName) |
(package private) void |
setProviderClientID() |
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) |
String |
toString()
String image of the connection.
|
void |
unregisterMBean() |
public static org.objectweb.util.monolog.api.Logger logger
private RequestMultiplexer mtpx
private Requestor requestor
private ConnectionMetaData metaData
private Connection.AtomicCounter sessionsC
private Connection.AtomicCounter messagesC
private Connection.AtomicCounter subsC
private String proxyId
private int key
private FactoryParameters factoryParameters
private int status
private Vector sessions
private Vector cconsumers
private Connection.Closer closer
private String stringImage
private int hashCode
private Identity identity
private String clientID
private boolean lockClientID
protected String JMXBeanBaseName
boolean checkThread()
boolean checkCLSession(Session session)
boolean checkCLMessageProducer(Session session, MessageProducer mp)
public void lockClientId()
public void open(FactoryParameters factoryParameters, RequestChannel requestChannel) throws JMSException
Connection
.factoryParameters
- The factory parameters.requestChannel
- The actual connection to wrap.JMSSecurityException
- If the user identification is incorrect.IllegalStateException
- If the server is not listening.JMSException
public void setJMXBeanBaseName(String JMXBeanBaseName)
public String getJMXBeanName()
public void unregisterMBean()
private void setStatus(int status)
public boolean isStopped()
isStopped
in interface ConnectionMBean
public String toString()
public boolean equals(Object obj)
true
if the parameter is a Connection
instance
sharing the same proxy identifier and connection key.public final long getTxPendingTimer()
getTxPendingTimer
in interface ConnectionMBean
FactoryParameters.txPendingTimer
public final boolean getImplicitAck()
This attribute is inherited from FactoryParameters, by default false.
getImplicitAck
in interface ConnectionMBean
FactoryParameters.implicitAck
,
Session.isImplicitAck()
public final boolean getAsyncSend()
Non persistent messages are always sent without acknowledgment.
This attribute is inherited from FactoryParameters, by default false, persistent messages are sent with acknowledge.
getAsyncSend
in interface ConnectionMBean
FactoryParameters.asyncSend
,
Session.isAsyncSend()
public final int getQueueMessageReadMax()
This attribute is inherited from FactoryParameters, default value is 1.
getQueueMessageReadMax
in interface ConnectionMBean
FactoryParameters.queueMessageReadMax
,
Session.getQueueMessageReadMax()
public final int getTopicAckBufferMax()
This attribute is inherited from FactoryParameters, default value is 0.
getTopicAckBufferMax
in interface ConnectionMBean
FactoryParameters.topicAckBufferMax
,
Session.getTopicAckBufferMax()
public final int getTopicPassivationThreshold()
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.
getTopicPassivationThreshold
in interface ConnectionMBean
FactoryParameters.topicPassivationThreshold
,
Session.getTopicPassivationThreshold()
public final int getTopicActivationThreshold()
This threshold is the minimum messages number below which the subscription is activated.
This attribute is inherited from FactoryParameters, default value is 0.
getTopicActivationThreshold
in interface ConnectionMBean
FactoryParameters.topicActivationThreshold
,
Session.getTopicActivationThreshold()
public final int getCompressedMinSize()
FactoryParameters.compressedMinSize
public final int getCompressionLevel()
FactoryParameters.compressionLevel
public final String getOutLocalAddress()
This attribute is inherited from FactoryParameters.
getOutLocalAddress
in interface ConnectionMBean
FactoryParameters.outLocalAddress
public final int getOutLocalPort()
This attribute is inherited from FactoryParameters.
getOutLocalPort
in interface ConnectionMBean
FactoryParameters.outLocalPort
final List getInInterceptors()
called
when receiving
a message.
final List getOutInterceptors()
called
when sending
a message.
protected final void checkClosed() throws IllegalStateException
IllegalStateException
public ConnectionConsumer createConnectionConsumer(Destination dest, String selector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
createConnectionConsumer
in interface Connection
dest
- the destination to access.selector
- 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 this 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.IllegalStateException
- If the connection is closed.InvalidSelectorException
- If the selector syntax is wrong.InvalidDestinationException
- If the target destination does
not exist.JMSException
- If the method fails for any other reason.public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subName, String selector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
createDurableConnectionConsumer
in interface Connection
topic
- the topic to access.subName
- durable subscription name.selector
- 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 this 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.IllegalStateException
- If the connection is closed.InvalidSelectorException
- If the selector syntax is wrong.InvalidDestinationException
- If the target topic does
not exist.JMSException
- If the method fails for any other reason.private ConnectionConsumer createConnectionConsumer(Destination dest, String subName, String selector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
JMSException
public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException
createSession
in interface Connection
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.
Additionnaly Joram defines INDIVIDUAL_ACKNOWLEDGE: With this acknowledgment mode,
the client acknowledges a consumed message by calling the message's acknowledge
method. Contrary to CLIENT_ACKNOWLEDGE mode this mode allows to acknowledge only
the specified message.IllegalStateException
- If the connection is closed.JMSException
- In case of an invalid acknowledge mode.public Session createSession() throws JMSException
In a Java SE environment or in the Java EE application client container:
Session.AUTO_ACKNOWLEDGE
For a definition of the meaning of this acknowledgement mode see the link below.
JMSException
public Session createSession(int sessionMode) throws JMSException
sessionMode
- In a Java SE environment or in the Java EE application client container:
transacted
is set to true
then the session
will use a local transaction which may subsequently be committed or rolled back
by calling the session's commit
or rollback
methods.
The argument acknowledgeMode
is ignored.
transacted
is set to false
then the session
will be non-transacted. In this case the argument acknowledgeMode
is used to specify how messages received by this session will be acknowledged.
The permitted values are
Session.CLIENT_ACKNOWLEDGE
,
Session.AUTO_ACKNOWLEDGE
and
Session.DUPS_OK_ACKNOWLEDGE
.
For a definition of the meaning of these acknowledgement modes see the links below.
JMSException
- in case of invalid session modeprotected void addSession(Session session)
public void setExceptionListener(ExceptionListener listener) throws JMSException
The 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.
setExceptionListener
in interface Connection
listener
- the exception listener.IllegalStateException
- If the connection is closed.JMSException
public ExceptionListener getExceptionListener() throws JMSException
getExceptionListener
in interface Connection
IllegalStateException
- If the connection is closed.JMSException
public void setClientID(String clientID) throws JMSException
setClientID
in interface Connection
clientID
- the unique client identifier.IllegalStateException
- if the JMS client attempts to set a connection's client ID at the wrong time or
when it has been administratively configured.JMSException
void setProviderClientID() throws JMSException
JMSException
private void addClientIDToProxy(String clientID) throws JMSException
JMSException
public String getClientID() throws JMSException
getClientID
in interface Connection
getClientID
in interface ConnectionMBean
IllegalStateException
- If the connection is closed.JMSException
public ConnectionMetaData getMetaData() throws JMSException
getMetaData
in interface Connection
IllegalStateException
- If the connection is closed.JMSException
ConnectionMetadata
public void start() throws JMSException
Starts (or restarts) the connection's delivery of incoming messages. A call to start on a connection that has already been started is ignored.
start
in interface Connection
start
in interface ConnectionMBean
IllegalStateException
- If the connection is closed or broken.JMSException
public void stop() throws JMSException
Temporarily stops the 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.
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. This call blocks until receives and/or message listeners in progress have completed, it must not return until delivery of messages has paused.
stop
in interface Connection
stop
in interface ConnectionMBean
IllegalStateException
- If the connection is closed or broken.JMSException
public void close() throws JMSException
In order to free significant resources allocated on behalf of a connection, clients should close connections when they are not needed. Closing a connection automatically close all related sessions, producers, and consumers and causes all temporary destinations to be deleted.
close
in interface Connection
close
in interface ConnectionMBean
JMSException
- Actually never thrown.javax.jms.Connection.close()
void doClose()
public void cleanup()
String nextSessionId()
String nextMessageId()
String nextSubName()
void closeSession(Session session)
void closeConnectionConsumer(MultiSessionConsumer cc)
AbstractJmsReply syncRequest(AbstractJmsRequest request) throws JMSException
JMSException
void checkConsumers(String agentId) throws JMSException
JMSException
protected final RequestMultiplexer getRequestMultiplexer()
public ConnectionConsumer createSharedConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
JMSException
public ConnectionConsumer createSharedDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException
JMSException
void openMessageConsumer(String targetName)
boolean isOpenMessageConsumer(String targetName)
boolean closeMessageConsumer(String targetName)
Copyright © 2015 ScalAgent D.T.. All Rights Reserved.