Class AbstractConnection
- java.lang.Object
-
- net.timewalker.ffmq4.common.connection.AbstractConnection
-
- All Implemented Interfaces:
javax.jms.Connection
- Direct Known Subclasses:
LocalConnection,RemoteConnection
public abstract class AbstractConnection extends Object implements javax.jms.Connection
Base implementation for a JMS connection
-
-
Field Summary
Fields Modifier and Type Field Description protected StringclientIDprotected booleanclosedprotected ReadWriteLockexternalAccessLockprotected Stringidprotected IntegerIDProvideridProviderprotected booleanstarted
-
Constructor Summary
Constructors Constructor Description AbstractConnection(String clientID)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckNotClosed()Check that the connection is not closedvoidclose()javax.jms.ConnectionConsumercreateConnectionConsumer(javax.jms.Destination destination, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)javax.jms.ConnectionConsumercreateDurableConnectionConsumer(javax.jms.Topic topic, String subscriptionName, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)abstract voiddeleteTemporaryQueue(String queueName)Delete a temporary queueabstract voiddeleteTemporaryTopic(String topicName)Delete a temporary topicvoidexceptionOccured(javax.jms.JMSException exception)Triggered when a JMSException is internally catchedprotected voidfinalize()StringgetClientID()intgetConsumersCount()Get the number of active producers for this connectionvoidgetEntitiesDescription(StringBuilder sb)Get a description of entities held by this objectjavax.jms.ExceptionListenergetExceptionListener()StringgetId()Get the connection idjavax.jms.ConnectionMetaDatagetMetaData()intgetProducersCount()Get the number of active producers for this connectionintgetSessionsCount()Get the number of active sessions for this connectionbooleanisRegisteredTemporaryQueue(String queueName)Check if a temporary queue was registered with this connectionbooleanisRegisteredTemporaryTopic(String topicName)Check if a temporary topic was registered with this connectionbooleanisStarted()Check if the connection is started NOT SYNCHRONIZED TO AVOID DEADLOCKSAbstractSessionlookupRegisteredSession(IntegerID sessionId)Lookup a registered sessionprotected voidonConnectionClose()protected voidonConnectionClosed()protected voidregisterSession(AbstractSession sessionToAdd)Register a sessionvoidregisterTemporaryQueue(String queueName)Register a temporary queue namevoidregisterTemporaryTopic(String topicName)Register a temporary topic namevoidsetClientID(String clientID)voidsetExceptionListener(javax.jms.ExceptionListener listener)StringtoString()voidunregisterSession(AbstractSession sessionToRemove)Unregister a sessionvoidunregisterTemporaryQueue(String queueName)Unregister a temporary queue namevoidunregisterTemporaryTopic(String topicName)Unregister a temporary topic nameprotected voidwaitForDeliverySync()Wait for sessions to finish the current deliveridispatchingprotected voidwakeUpLocalConsumers()Wake up all children consumers (Used by LocalConnection only)
-
-
-
Field Detail
-
id
protected String id
-
clientID
protected String clientID
-
started
protected boolean started
-
closed
protected boolean closed
-
idProvider
protected IntegerIDProvider idProvider
-
externalAccessLock
protected ReadWriteLock externalAccessLock
-
-
Constructor Detail
-
AbstractConnection
public AbstractConnection(String clientID)
Constructor
-
-
Method Detail
-
getId
public String getId()
Get the connection id- Returns:
- the id
-
getClientID
public String getClientID() throws javax.jms.JMSException
- Specified by:
getClientIDin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
getMetaData
public javax.jms.ConnectionMetaData getMetaData()
- Specified by:
getMetaDatain interfacejavax.jms.Connection
-
setClientID
public void setClientID(String clientID) throws javax.jms.JMSException
- Specified by:
setClientIDin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
getExceptionListener
public javax.jms.ExceptionListener getExceptionListener()
- Specified by:
getExceptionListenerin interfacejavax.jms.Connection
-
setExceptionListener
public void setExceptionListener(javax.jms.ExceptionListener listener) throws javax.jms.JMSException- Specified by:
setExceptionListenerin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
exceptionOccured
public final void exceptionOccured(javax.jms.JMSException exception)
Triggered when a JMSException is internally catched
-
registerTemporaryQueue
public final void registerTemporaryQueue(String queueName)
Register a temporary queue name
-
unregisterTemporaryQueue
public final void unregisterTemporaryQueue(String queueName)
Unregister a temporary queue name
-
isRegisteredTemporaryQueue
public final boolean isRegisteredTemporaryQueue(String queueName)
Check if a temporary queue was registered with this connection
-
registerTemporaryTopic
public final void registerTemporaryTopic(String topicName)
Register a temporary topic name
-
unregisterTemporaryTopic
public final void unregisterTemporaryTopic(String topicName)
Unregister a temporary topic name
-
isRegisteredTemporaryTopic
public final boolean isRegisteredTemporaryTopic(String topicName)
Check if a temporary topic was registered with this connection
-
deleteTemporaryQueue
public abstract void deleteTemporaryQueue(String queueName) throws javax.jms.JMSException
Delete a temporary queue- Throws:
javax.jms.JMSException
-
deleteTemporaryTopic
public abstract void deleteTemporaryTopic(String topicName) throws javax.jms.JMSException
Delete a temporary topic- Throws:
javax.jms.JMSException
-
close
public final void close()
- Specified by:
closein interfacejavax.jms.Connection
-
onConnectionClose
protected void onConnectionClose()
-
onConnectionClosed
protected void onConnectionClosed()
-
wakeUpLocalConsumers
protected final void wakeUpLocalConsumers()
Wake up all children consumers (Used by LocalConnection only)
-
waitForDeliverySync
protected final void waitForDeliverySync()
Wait for sessions to finish the current deliveridispatching
-
lookupRegisteredSession
public final AbstractSession lookupRegisteredSession(IntegerID sessionId)
Lookup a registered session
-
registerSession
protected final void registerSession(AbstractSession sessionToAdd)
Register a session
-
unregisterSession
public final void unregisterSession(AbstractSession sessionToRemove)
Unregister a session
-
checkNotClosed
protected final void checkNotClosed() throws javax.jms.JMSExceptionCheck that the connection is not closed- Throws:
javax.jms.JMSException
-
createConnectionConsumer
public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException- Specified by:
createConnectionConsumerin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
createDurableConnectionConsumer
public javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic, String subscriptionName, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException- Specified by:
createDurableConnectionConsumerin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
finalize
protected void finalize() throws Throwable
-
isStarted
public boolean isStarted()
Check if the connection is started NOT SYNCHRONIZED TO AVOID DEADLOCKS
-
getSessionsCount
public int getSessionsCount()
Get the number of active sessions for this connection- Returns:
- the number of active sessions for this connection
-
getConsumersCount
public int getConsumersCount()
Get the number of active producers for this connection- Returns:
- the number of active producers for this connection
-
getProducersCount
public int getProducersCount()
Get the number of active producers for this connection- Returns:
- the number of active producers for this connection
-
getEntitiesDescription
public void getEntitiesDescription(StringBuilder sb)
Get a description of entities held by this object
-
-