Class WmConnectionImpl
- java.lang.Object
-
- com.webmethods.locks.Node
-
- com.webmethods.jms.impl.WmConnectionImpl
-
- All Implemented Interfaces:
WmConnection
,javax.jms.Connection
- Direct Known Subclasses:
WmClusterConnectionImpl
,WmClusterConnectionWorker
,WmQueueConnectionImpl
,WmTopicConnectionImpl
,WmXAConnectionImpl
public class WmConnectionImpl extends Node implements WmConnection
JMS Connection instance is a thread safe object.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
_accessLabelHint
protected java.util.List
_brokerURLs
protected java.lang.String
_clientID
protected boolean
_closeClusterConnection
protected boolean
_closed
protected boolean
_closeInProgress
protected javax.jms.ExceptionListener
_exceptionListener
protected java.util.concurrent.atomic.AtomicBoolean
_exceptionListenerCalledOnce
A boolean to check whether the exception listener has been called.protected WmConnectionFactoryImpl
_factory
boolean
_isXA
boolean
_isXACloseCalled
protected boolean
_logApi
protected java.lang.String
_password
protected ProtocolHandler
_protocolHandler
protected java.util.Vector<javax.jms.Session>
_sessions
protected boolean
_setClientIDProhibited
protected java.util.concurrent.atomic.AtomicBoolean
_started
protected java.lang.String
_uniqueID
protected java.lang.String
_username
protected static int
AUTO_RECONNECT
protected WmConnectionStatus
connectionStatus
boolean
isSSLEnabled
protected static int
NO_RECONNECT
protected static int
RECONNECT
-
Fields inherited from class com.webmethods.locks.Node
_lockManager
-
Fields inherited from interface com.webmethods.jms.WmConnection
ENCRYPT_LEVEL_ENCRYPTION, ENCRYPT_LEVEL_NO_ENCRYPTION, ENCRYPT_LEVEL_US_DOMESTIC, ENCRYPT_LEVEL_US_EXPORT
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
WmConnectionImpl()
Called only by subclass constructors.protected
WmConnectionImpl(WmConnectionFactoryImpl factory, java.lang.String username, java.lang.String password)
Constructor.protected
WmConnectionImpl(WmConnectionFactoryImpl factory, java.lang.String username, java.lang.String password, java.lang.String accessLabelHint)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.lang.String
acknowledgeModeToString(int acknowledgeMode)
protected void
addConnectionConsumer(WmConnectionConsumerImpl connectionConsumer)
void
addSession(WmSessionImpl session)
void
addTemporaryDestination(WmDestinationImpl destination)
void
canPublish(javax.jms.Destination destination)
protected void
checkLocalQueue(WmQueueImpl queue)
protected void
checkState()
void
close()
Closes the connection.protected void
closeSessions()
protected void
commit(long transactionID)
void
commit(java.lang.String xaTransactionID)
protected boolean
containsTemporaryDestination(WmDestinationImpl destination)
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.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.QueueSession
createQueueSession(boolean transacted, int acknowledgeMode)
Creates aQueueSession
object.javax.jms.Session
createSession(boolean transacted, int acknowledgeMode)
Creates aSession
object.javax.jms.TopicSession
createTopicSession(boolean transacted, int acknowledgeMode)
Creates aTopicSession
object.javax.jms.XAQueueSession
createXAQueueSession()
Creates anXAQueueSession
object.javax.jms.XASession
createXASession()
Creates anXASession
object.javax.jms.XATopicSession
createXATopicSession()
Creates anXATopicSession
object.protected void
endTransaction(long transactionID, boolean success)
protected void
forget(java.lang.String transactionID)
short[]
getAccessLabel()
Get the client access labeljava.lang.String
getBroker()
Get the Broker to which this connection is currently connected.java.lang.String
getBrokerName()
Get the Broker name to which this connection is currently connected.java.lang.String
getClientID()
Gets the client identifier for this connection.java.lang.String
getClientIDUnsafe()
This is to obtain the clientID without any checkstate.WmConnectionStatus
getConnectionStatus()
protected WmTopicSubscriberImpl
getDurableSubscriber(java.lang.String name)
javax.jms.ExceptionListener
getExceptionListener()
Gets theExceptionListener
object for this connection.javax.jms.ConnectionFactory
getFactory()
Returns the connection factory used to create this connection.WmMarshalIn
getMarshalIn()
java.lang.Object
getMarshalInUserData()
WmMarshalOut
getMarshalOut()
java.lang.Object
getMarshalOutUserData()
WmMessageFactory
getMessageFactory()
javax.jms.ConnectionMetaData
getMetaData()
Gets the metadata for this connection.WmNotificationListener
getNotificationListener()
Gets theNotificationListener
object for this connection.int
getPublishProcessState()
int
getSSLEncryptionLevel()
Get the SSL encryption level.java.util.Properties
getSSLServerCertificate()
Get the JMS Broker's SSL certificate properties.java.util.Vector
getTemporaryDestinations()
java.lang.String
getTerritory()
Get the territory of the Broker to which this connection is currently connected.protected java.lang.String
getUniqueID()
java.lang.String
getUserName()
protected void
initConnection(boolean enableCluster)
Moved the initialization of out the constructor so subclasses can have a chance to override some of the behaviors.protected int
initializeConnection(java.lang.String clientID)
protected int
initializeReceiver(WmQueueImpl queue, int reconnect)
protected int
initializeSubscriber(WmTopicImpl topic, java.lang.String durableName, boolean ackNonPersistent, int reconnect)
void
initKeepAliveThread()
A graceful handling of keep alive thread.void
invokeExceptionListener(java.lang.Exception exception)
void
invokeNotificationListener(WmNotification notice)
boolean
isClosed()
boolean
isSSLEnabled()
boolean
isStarted()
Returns whether the connection has been started.boolean
isTransactionCompleted()
void
markForClosure(boolean exceptionOccurred)
Marks the connection for closure.void
ping()
Pings the Broker to determine if there is network connectivity.protected void
prepare(long transactionID)
protected void
prepare(java.lang.String xaTransactionID)
protected void
publish(long transactionID, WmMessageImpl[] messages, int deliveryMode, boolean deliver)
void
publish(long transactionID, WmMessageImpl[] messages, int deliveryMode, boolean deliver, boolean confirmDelivry)
protected void
publish(long transactionID, WmMessageImpl message, int deliveryMode, boolean deliver)
void
publish(long transactionID, WmMessageImpl message, int deliveryMode, boolean deliver, boolean confirmDelivry)
protected java.lang.String[]
recover(int flags, long lastRetrivedTxID)
protected void
removeConnectionConsumer(WmConnectionConsumerImpl connectionConsumer)
protected void
removeSession(WmSessionImpl session)
protected void
removeTemporaryDestination(WmDestinationImpl destination)
protected void
rollback(long transactionID)
protected void
rollback(java.lang.String xaTransactionID)
void
sendKeepAliveResponse()
Send response to Broker's keep alive requestvoid
setClientID(java.lang.String clientID)
Sets the client identifier for this connection.void
setConnectionStatus(WmConnectionStatus connectionStatus)
void
setExceptionListener(javax.jms.ExceptionListener listener)
Sets an exception listener for this connection.void
setNotificationListener(WmNotificationListener listener)
Sets an notification listener for this connection.void
setParentConnection(WmClusterConnectionImpl parentConnection)
void
setSSLEnabled(boolean isSSLEnabled)
void
start()
Starts (or restarts) a connection's delivery of incoming messages.protected void
startSessions()
protected long
startTransaction()
protected long
startTransaction(int timeout)
protected long
startTransaction(java.lang.String xaTransactionID, int timeout, boolean join)
void
stop()
Temporarily stops a connection's delivery of incoming messages.protected void
stopSessions()
This method will be called from within stop(), so it is an assumption that the threads entering this already would have taken relevant locks to make the method threadsafe.java.lang.String
toString()
protected void
unsubscribeDurableSubscriber(java.lang.String name)
-
Methods inherited from class com.webmethods.locks.Node
getLockManager, getParent
-
-
-
-
Field Detail
-
RECONNECT
protected static final int RECONNECT
- See Also:
- Constant Field Values
-
NO_RECONNECT
protected static final int NO_RECONNECT
- See Also:
- Constant Field Values
-
AUTO_RECONNECT
protected static final int AUTO_RECONNECT
- See Also:
- Constant Field Values
-
_factory
protected WmConnectionFactoryImpl _factory
-
_protocolHandler
protected ProtocolHandler _protocolHandler
-
_started
protected volatile java.util.concurrent.atomic.AtomicBoolean _started
-
_closed
protected volatile boolean _closed
-
_closeInProgress
protected volatile boolean _closeInProgress
-
_setClientIDProhibited
protected volatile boolean _setClientIDProhibited
-
_logApi
protected boolean _logApi
-
_username
protected java.lang.String _username
-
_password
protected java.lang.String _password
-
_accessLabelHint
protected java.lang.String _accessLabelHint
-
_exceptionListener
protected volatile javax.jms.ExceptionListener _exceptionListener
-
_clientID
protected volatile java.lang.String _clientID
-
_sessions
protected java.util.Vector<javax.jms.Session> _sessions
-
_uniqueID
protected java.lang.String _uniqueID
-
_brokerURLs
protected java.util.List _brokerURLs
-
_isXA
public boolean _isXA
-
_isXACloseCalled
public boolean _isXACloseCalled
-
_closeClusterConnection
protected volatile boolean _closeClusterConnection
-
isSSLEnabled
public boolean isSSLEnabled
-
connectionStatus
protected WmConnectionStatus connectionStatus
-
_exceptionListenerCalledOnce
protected volatile java.util.concurrent.atomic.AtomicBoolean _exceptionListenerCalledOnce
A boolean to check whether the exception listener has been called.
-
-
Constructor Detail
-
WmConnectionImpl
protected WmConnectionImpl(WmConnectionFactoryImpl factory, java.lang.String username, java.lang.String password) throws javax.jms.JMSException
Constructor.- Parameters:
factory
- the factory that created this connectionusername
- the caller's user namepassword
- the caller's password- Throws:
javax.jms.JMSException
-
WmConnectionImpl
protected WmConnectionImpl(WmConnectionFactoryImpl factory, java.lang.String username, java.lang.String password, java.lang.String accessLabelHint) throws javax.jms.JMSException
Constructor- Parameters:
factory
-username
-password
-accessLabelHint
-- Throws:
javax.jms.JMSException
-
WmConnectionImpl
protected WmConnectionImpl()
Called only by subclass constructors.
-
-
Method Detail
-
setParentConnection
public void setParentConnection(WmClusterConnectionImpl parentConnection)
-
initConnection
protected void initConnection(boolean enableCluster) throws javax.jms.JMSException
Moved the initialization of out the constructor so subclasses can have a chance to override some of the behaviors.- Throws:
javax.jms.JMSException
-
createSession
public javax.jms.Session createSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
Creates aSession
object.- Specified by:
createSession
in interfacejavax.jms.Connection
- Parameters:
transacted
- indicates whether the session is transactedacknowledgeMode
- indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values areSession.AUTO_ACKNOWLEDGE
,Session.CLIENT_ACKNOWLEDGE
, andSession.DUPS_OK_ACKNOWLEDGE
.- Returns:
- a newly created session
- Throws:
javax.jms.JMSException
- if theConnection
object fails to create a session due to some internal error or lack of support for the specific transaction and acknowledgement mode.
-
createXASession
public javax.jms.XASession createXASession() throws javax.jms.JMSException
Creates anXASession
object.- Returns:
- a newly created
XASession
- Throws:
javax.jms.JMSException
- if theXAConnection
object fails to create anXASession
due to some internal error.
-
createTopicSession
public javax.jms.TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
Creates aTopicSession
object.- Parameters:
transacted
- indicates whether the session is transactedacknowledgeMode
- indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values areSession.AUTO_ACKNOWLEDGE
,Session.CLIENT_ACKNOWLEDGE
, andSession.DUPS_OK_ACKNOWLEDGE
.- Returns:
- a newly created topic session
- Throws:
javax.jms.JMSException
- if theTopicConnection
object fails to create a session due to some internal error or lack of support for the specific transaction and acknowledgement mode.
-
createXATopicSession
public javax.jms.XATopicSession createXATopicSession() throws javax.jms.JMSException
Creates anXATopicSession
object.- Returns:
- a newly created XA topic session
- Throws:
javax.jms.JMSException
- if theXATopicConnection
object fails to create an XA topic session due to some internal error.
-
createQueueSession
public javax.jms.QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
Creates aQueueSession
object.- Parameters:
transacted
- indicates whether the session is transactedacknowledgeMode
- indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values areSession.AUTO_ACKNOWLEDGE
,Session.CLIENT_ACKNOWLEDGE
, andSession.DUPS_OK_ACKNOWLEDGE
.- Returns:
- a newly created queue session
- Throws:
javax.jms.JMSException
- if theQueueConnection
object fails to create a session due to some internal error or lack of support for the specific transaction and acknowledgement mode.
-
createXAQueueSession
public javax.jms.XAQueueSession createXAQueueSession() throws javax.jms.JMSException
Creates anXAQueueSession
object.- Returns:
- a newly created
XAQueueSession
- Throws:
javax.jms.JMSException
- if theXAQueueConnection
object fails to create an XA queue session due to some internal error.
-
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 thesetClientID
method.- Specified by:
getClientID
in interfacejavax.jms.Connection
- Returns:
- the unique client identifier
- Throws:
javax.jms.JMSException
- if the JMS provider fails to return the client ID for this connection due to some internal error.
-
getClientIDUnsafe
public java.lang.String getClientIDUnsafe()
This is to obtain the clientID without any checkstate.
-
setClientID
public void setClientID(java.lang.String clientID) 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 theConnection
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 anIllegalStateException
.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 anInvalidClientIDException
.- Specified by:
setClientID
in interfacejavax.jms.Connection
- Parameters:
clientID
- the unique client identifier- Throws:
javax.jms.JMSException
- if the JMS provider fails to set the client ID for this connection due to some internal error.javax.jms.InvalidClientIDException
- if the JMS client specifies an invalid or duplicate client ID.javax.jms.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 javax.jms.ConnectionMetaData getMetaData() throws javax.jms.JMSException
Gets the metadata for this connection.- Specified by:
getMetaData
in interfacejavax.jms.Connection
- Returns:
- the connection metadata
- Throws:
javax.jms.JMSException
- if the JMS provider fails to get the connection metadata for this connection.
-
getExceptionListener
public javax.jms.ExceptionListener getExceptionListener() throws javax.jms.JMSException
Gets theExceptionListener
object for this connection. Not everyConnection
has anExceptionListener
associated with it.- Specified by:
getExceptionListener
in interfacejavax.jms.Connection
- Returns:
- the
ExceptionListener
for this connection, or null. if noExceptionListener
is associated with this connection. - Throws:
javax.jms.JMSException
- if the JMS provider fails to get theExceptionListener
for this connection.
-
getNotificationListener
public WmNotificationListener getNotificationListener() throws javax.jms.JMSException
Gets theNotificationListener
object for this connection. Not everyConnection
has anNotificationListener
associated with it.- Returns:
- the
NotificationListener
for this connection, or null. if noNotificationListener
is associated with this connection. - Throws:
javax.jms.JMSException
- if the JMS provider fails to get theNotificationListener
for this 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'sonException
method, passing it aJMSException
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 interfacejavax.jms.Connection
- Parameters:
listener
- the exception listener- Throws:
javax.jms.JMSException
- if the JMS provider fails to set the exception listener for this connection.
-
setNotificationListener
public void setNotificationListener(WmNotificationListener listener) throws javax.jms.JMSException
Sets an notification listener for this connection.An notification 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.
- Parameters:
listener
- the exception listener- Throws:
javax.jms.JMSException
- if the JMS provider fails to set the exception listener for this connection.
-
start
public void start() throws javax.jms.JMSException
Starts (or restarts) a connection's delivery of incoming messages. A call tostart
on a connection that has already been started is ignored.- Specified by:
start
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
- if the JMS provider fails to start message delivery due to some internal error.
-
stop
public void stop() throws javax.jms.JMSException
Temporarily stops a connection's delivery of incoming messages. Delivery can be restarted using the connection'sstart
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 forreceive
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, thestop
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 interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
- if the JMS provider fails to stop message delivery due to some internal error.
-
markForClosure
public void markForClosure(boolean exceptionOccurred) throws javax.jms.JMSException
Marks the connection for closure.- Throws:
javax.jms.JMSException
-
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
androllback
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 anIllegalStateException
. Closing a closed connection must NOT throw an exception.- Specified by:
close
in interfacejavax.jms.Connection
- Throws:
javax.jms.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.
-
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 interfacejavax.jms.Connection
- Parameters:
destination
- the destination to accessmessageSelector
- 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 consumermaxMessages
- the maximum number of messages that can be assigned to a server session at one time- Returns:
- the connection consumer
- Throws:
javax.jms.JMSException
- if theConnection
object fails to create a connection consumer due to some internal error or invalid arguments forsessionPool
andmessageSelector
.javax.jms.InvalidDestinationException
- if an invalid destination is specified.javax.jms.InvalidSelectorException
- if the message selector is invalid.
-
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.- Parameters:
topic
- the topic to accessmessageSelector
- 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 consumermaxMessages
- the maximum number of messages that can be assigned to a server session at one time- Returns:
- the connection consumer
- Throws:
javax.jms.JMSException
- if theTopicConnection
object fails to create a connection consumer due to some internal error or invalid arguments forsessionPool
andmessageSelector
.javax.jms.InvalidDestinationException
- if an invalid topic is specified.javax.jms.InvalidSelectorException
- if the message selector is invalid.
-
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.- Parameters:
queue
- the queue to accessmessageSelector
- 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 consumermaxMessages
- the maximum number of messages that can be assigned to a server session at one time- Returns:
- the connection consumer
- Throws:
javax.jms.JMSException
- if theQueueConnection
object fails to create a connection consumer due to some internal error or invalid arguments forsessionPool
andmessageSelector
.javax.jms.InvalidDestinationException
- if an invalid queue is specified.javax.jms.InvalidSelectorException
- if the message selector is invalid.
-
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 interfacejavax.jms.Connection
- Parameters:
topic
- topic to accesssubscriptionName
- durable subscription namemessageSelector
- 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 consumermaxMessages
- the maximum number of messages that can be assigned to a server session at one time- Returns:
- the durable connection consumer
- Throws:
javax.jms.JMSException
- if theConnection
object fails to create a connection consumer due to some internal error or invalid arguments forsessionPool
andmessageSelector
.javax.jms.InvalidDestinationException
- if an invalid destination is specified.javax.jms.InvalidSelectorException
- if the message selector is invalid.
-
getFactory
public javax.jms.ConnectionFactory getFactory() throws javax.jms.JMSException
Returns the connection factory used to create this connection.- Specified by:
getFactory
in interfaceWmConnection
- Returns:
- the ConnectionFactory used to create his Connection
- Throws:
javax.jms.JMSException
- if the JMS provider fails to get the connection factory for this connection.
-
getBroker
public java.lang.String getBroker() throws javax.jms.JMSException
Get the Broker to which this connection is currently connected.- Specified by:
getBroker
in interfaceWmConnection
- Returns:
- the Broker name
- Throws:
javax.jms.JMSException
- if the JMS provider fails to get the Broker for this connection
-
getBrokerName
public java.lang.String getBrokerName() throws javax.jms.JMSException
Get the Broker name to which this connection is currently connected.- Returns:
- the Broker short name
- Throws:
javax.jms.JMSException
- if the JMS provider fails to get the Broker name for this connection
-
getTerritory
public java.lang.String getTerritory() throws javax.jms.JMSException
Get the territory of the Broker to which this connection is currently connected.- Specified by:
getTerritory
in interfaceWmConnection
- Returns:
- the territory name
- Throws:
javax.jms.JMSException
- if the JMS provider fails to get the territory
-
getSSLEncryptionLevel
public int getSSLEncryptionLevel() throws javax.jms.JMSException
Get the SSL encryption level.- Specified by:
getSSLEncryptionLevel
in interfaceWmConnection
- Returns:
WmConnection.ENCRYPT_LEVEL_NO_ENCRYPTION
orWmConnection.ENCRYPT_LEVEL_ENCRYPTION
- Throws:
javax.jms.JMSException
- if the JMS provider fails to get the encryption level for this connection.
-
getSSLServerCertificate
public java.util.Properties getSSLServerCertificate() throws javax.jms.JMSException
Get the JMS Broker's SSL certificate properties. The included property names are: "subjectDn", "issuerDn", "status" "serialNumber", "beginDate", "endDate".- Specified by:
getSSLServerCertificate
in interfaceWmConnection
- Returns:
- the server certificate properties, or
null
if not an SSL connection - Throws:
javax.jms.JMSException
- if the JMS provider fails to get the server certificate for this connection.
-
ping
public void ping() throws javax.jms.JMSException
Pings the Broker to determine if there is network connectivity.- Specified by:
ping
in interfaceWmConnection
- Throws:
javax.jms.JMSException
- if the JMS provider fails to ping the Broker
-
getAccessLabel
public short[] getAccessLabel() throws javax.jms.JMSException
Description copied from interface:WmConnection
Get the client access label- Specified by:
getAccessLabel
in interfaceWmConnection
- Returns:
- access labels
- Throws:
javax.jms.JMSException
-
getPublishProcessState
public int getPublishProcessState() throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
checkState
protected void checkState() throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
invokeNotificationListener
public void invokeNotificationListener(WmNotification notice)
-
invokeExceptionListener
public void invokeExceptionListener(java.lang.Exception exception)
-
initializeConnection
protected int initializeConnection(java.lang.String clientID) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
initializeReceiver
protected int initializeReceiver(WmQueueImpl queue, int reconnect) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
initializeSubscriber
protected int initializeSubscriber(WmTopicImpl topic, java.lang.String durableName, boolean ackNonPersistent, int reconnect) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
startTransaction
protected long startTransaction() throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
startTransaction
protected long startTransaction(int timeout) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
startTransaction
protected long startTransaction(java.lang.String xaTransactionID, int timeout, boolean join) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
prepare
protected void prepare(java.lang.String xaTransactionID) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
prepare
protected void prepare(long transactionID) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
rollback
protected void rollback(java.lang.String xaTransactionID) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
rollback
protected void rollback(long transactionID) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
endTransaction
protected void endTransaction(long transactionID, boolean success) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
commit
public void commit(java.lang.String xaTransactionID) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
commit
protected void commit(long transactionID) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
recover
protected java.lang.String[] recover(int flags, long lastRetrivedTxID) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
forget
protected void forget(java.lang.String transactionID) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
addSession
public void addSession(WmSessionImpl session)
-
removeSession
protected void removeSession(WmSessionImpl session)
-
startSessions
protected void startSessions() throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
stopSessions
protected void stopSessions() throws javax.jms.JMSException
This method will be called from within stop(), so it is an assumption that the threads entering this already would have taken relevant locks to make the method threadsafe.- Throws:
javax.jms.JMSException
-
checkLocalQueue
protected void checkLocalQueue(WmQueueImpl queue) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
addConnectionConsumer
protected void addConnectionConsumer(WmConnectionConsumerImpl connectionConsumer)
-
removeConnectionConsumer
protected void removeConnectionConsumer(WmConnectionConsumerImpl connectionConsumer)
-
addTemporaryDestination
public void addTemporaryDestination(WmDestinationImpl destination)
-
getTemporaryDestinations
public java.util.Vector getTemporaryDestinations()
-
removeTemporaryDestination
protected void removeTemporaryDestination(WmDestinationImpl destination)
-
containsTemporaryDestination
protected boolean containsTemporaryDestination(WmDestinationImpl destination)
-
getUniqueID
protected java.lang.String getUniqueID()
-
publish
public void publish(long transactionID, WmMessageImpl message, int deliveryMode, boolean deliver, boolean confirmDelivry) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
publish
public void publish(long transactionID, WmMessageImpl[] messages, int deliveryMode, boolean deliver, boolean confirmDelivry) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
publish
protected void publish(long transactionID, WmMessageImpl message, int deliveryMode, boolean deliver) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
publish
protected void publish(long transactionID, WmMessageImpl[] messages, int deliveryMode, boolean deliver) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
getDurableSubscriber
protected WmTopicSubscriberImpl getDurableSubscriber(java.lang.String name)
- Parameters:
name
-
-
unsubscribeDurableSubscriber
protected void unsubscribeDurableSubscriber(java.lang.String name) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
closeSessions
protected void closeSessions()
-
getMarshalOut
public WmMarshalOut getMarshalOut()
-
getMarshalOutUserData
public java.lang.Object getMarshalOutUserData()
-
getMarshalIn
public WmMarshalIn getMarshalIn()
-
getMarshalInUserData
public java.lang.Object getMarshalInUserData()
-
getMessageFactory
public WmMessageFactory getMessageFactory()
-
getUserName
public java.lang.String getUserName()
-
canPublish
public void canPublish(javax.jms.Destination destination) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
acknowledgeModeToString
protected static java.lang.String acknowledgeModeToString(int acknowledgeMode)
-
initKeepAliveThread
public void initKeepAliveThread()
A graceful handling of keep alive thread. Call this method when initialization of KeepAlive thread is needed. And this needs to be called whenever a reconnection of connection happens. Absolute care needs to be taken that it is not called within any synchronized block for reconnection, as that will lead to deadlock. LinkReader thread that tries for reconnect, after acquiring the lock will also enter this method. And if this method is called it will wait for the previous ConnectionKeepAlive method to go dead. But before that happens, even that thread needs to acquire the reconnect lock. So a deadlock happens.
-
sendKeepAliveResponse
public void sendKeepAliveResponse()
Send response to Broker's keep alive request
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isTransactionCompleted
public boolean isTransactionCompleted()
-
setSSLEnabled
public void setSSLEnabled(boolean isSSLEnabled)
-
isSSLEnabled
public boolean isSSLEnabled()
-
isClosed
public boolean isClosed()
-
getConnectionStatus
public WmConnectionStatus getConnectionStatus()
-
setConnectionStatus
public void setConnectionStatus(WmConnectionStatus connectionStatus)
-
isStarted
public boolean isStarted()
Returns whether the connection has been started.
-
-