Package org.messaginghub.pooled.jms
Class JmsPoolConnection
java.lang.Object
org.messaginghub.pooled.jms.JmsPoolConnection
- All Implemented Interfaces:
jakarta.jms.Connection
,jakarta.jms.QueueConnection
,jakarta.jms.TopicConnection
,AutoCloseable
,JmsPoolSessionEventListener
public class JmsPoolConnection
extends Object
implements jakarta.jms.TopicConnection, jakarta.jms.QueueConnection, JmsPoolSessionEventListener, AutoCloseable
Represents a proxy
Connection
which is-a TopicConnection
and
QueueConnection
which is pooled and on close()
will return
its reference to the ConnectionPool backing it.
NOTE this implementation is only intended for use when sending
messages. It does not deal with pooling of consumers.-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new PooledConnection instance that uses the given ConnectionPool to create and manage its resources. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
The PooledSession tracks all Sessions that it created and now we close them.protected void
Remove all of the temporary destinations created for this connection.void
close()
jakarta.jms.ConnectionConsumer
createConnectionConsumer
(jakarta.jms.Destination destination, String selector, jakarta.jms.ServerSessionPool serverSessionPool, int maxMessages) jakarta.jms.ConnectionConsumer
createConnectionConsumer
(jakarta.jms.Queue queue, String selector, jakarta.jms.ServerSessionPool serverSessionPool, int maxMessages) jakarta.jms.ConnectionConsumer
createConnectionConsumer
(jakarta.jms.Topic topic, String s, jakarta.jms.ServerSessionPool serverSessionPool, int maxMessages) jakarta.jms.ConnectionConsumer
createDurableConnectionConsumer
(jakarta.jms.Topic topic, String selector, String s1, jakarta.jms.ServerSessionPool serverSessionPool, int i) jakarta.jms.QueueSession
createQueueSession
(boolean transacted, int ackMode) jakarta.jms.Session
jakarta.jms.Session
createSession
(boolean transacted, int ackMode) jakarta.jms.Session
createSession
(int sessionMode) jakarta.jms.ConnectionConsumer
createSharedConnectionConsumer
(jakarta.jms.Topic topic, String subscriptionName, String selector, jakarta.jms.ServerSessionPool sessionPool, int maxMessages) jakarta.jms.ConnectionConsumer
createSharedDurableConnectionConsumer
(jakarta.jms.Topic topic, String subscriptionName, String selector, jakarta.jms.ServerSessionPool sessionPool, int maxMessages) jakarta.jms.TopicSession
createTopicSession
(boolean transacted, int ackMode) jakarta.jms.Connection
jakarta.jms.ExceptionListener
jakarta.jms.ConnectionMetaData
int
int
int
void
onSessionClosed
(JmsPoolSession session) Called when the PooledSession is closed.void
onTemporaryQueueCreate
(jakarta.jms.TemporaryQueue tempQueue) Called on successful creation of a new TemporaryQueue.void
onTemporaryTopicCreate
(jakarta.jms.TemporaryTopic tempTopic) Called on successful creation of a new TemporaryTopic.void
setClientID
(String clientID) void
setExceptionListener
(jakarta.jms.ExceptionListener exceptionListener) void
start()
void
stop()
toString()
-
Field Details
-
connection
-
-
Constructor Details
-
JmsPoolConnection
Creates a new PooledConnection instance that uses the given ConnectionPool to create and manage its resources. The ConnectionPool instance can be shared amongst many PooledConnection instances.- Parameters:
pool
- The connection and pool manager backing this proxy connection object.
-
-
Method Details
-
close
public void close() throws jakarta.jms.JMSException- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfacejakarta.jms.Connection
- Throws:
jakarta.jms.JMSException
-
start
public void start() throws jakarta.jms.JMSException- Specified by:
start
in interfacejakarta.jms.Connection
- Throws:
jakarta.jms.JMSException
-
stop
public void stop() throws jakarta.jms.JMSException- Specified by:
stop
in interfacejakarta.jms.Connection
- Throws:
jakarta.jms.JMSException
-
getMetaData
public jakarta.jms.ConnectionMetaData getMetaData() throws jakarta.jms.JMSException- Specified by:
getMetaData
in interfacejakarta.jms.Connection
- Throws:
jakarta.jms.JMSException
-
getExceptionListener
public jakarta.jms.ExceptionListener getExceptionListener() throws jakarta.jms.JMSException- Specified by:
getExceptionListener
in interfacejakarta.jms.Connection
- Throws:
jakarta.jms.JMSException
-
setExceptionListener
public void setExceptionListener(jakarta.jms.ExceptionListener exceptionListener) throws jakarta.jms.JMSException - Specified by:
setExceptionListener
in interfacejakarta.jms.Connection
- Throws:
jakarta.jms.JMSException
-
getClientID
- Specified by:
getClientID
in interfacejakarta.jms.Connection
- Throws:
jakarta.jms.JMSException
-
setClientID
- Specified by:
setClientID
in interfacejakarta.jms.Connection
- Throws:
jakarta.jms.JMSException
-
createConnectionConsumer
public jakarta.jms.ConnectionConsumer createConnectionConsumer(jakarta.jms.Destination destination, String selector, jakarta.jms.ServerSessionPool serverSessionPool, int maxMessages) throws jakarta.jms.JMSException - Specified by:
createConnectionConsumer
in interfacejakarta.jms.Connection
- Throws:
jakarta.jms.JMSException
-
createConnectionConsumer
public jakarta.jms.ConnectionConsumer createConnectionConsumer(jakarta.jms.Topic topic, String s, jakarta.jms.ServerSessionPool serverSessionPool, int maxMessages) throws jakarta.jms.JMSException - Specified by:
createConnectionConsumer
in interfacejakarta.jms.TopicConnection
- Throws:
jakarta.jms.JMSException
-
createDurableConnectionConsumer
public jakarta.jms.ConnectionConsumer createDurableConnectionConsumer(jakarta.jms.Topic topic, String selector, String s1, jakarta.jms.ServerSessionPool serverSessionPool, int i) throws jakarta.jms.JMSException - Specified by:
createDurableConnectionConsumer
in interfacejakarta.jms.Connection
- Specified by:
createDurableConnectionConsumer
in interfacejakarta.jms.TopicConnection
- Throws:
jakarta.jms.JMSException
-
createConnectionConsumer
public jakarta.jms.ConnectionConsumer createConnectionConsumer(jakarta.jms.Queue queue, String selector, jakarta.jms.ServerSessionPool serverSessionPool, int maxMessages) throws jakarta.jms.JMSException - Specified by:
createConnectionConsumer
in interfacejakarta.jms.QueueConnection
- Throws:
jakarta.jms.JMSException
-
createQueueSession
public jakarta.jms.QueueSession createQueueSession(boolean transacted, int ackMode) throws jakarta.jms.JMSException - Specified by:
createQueueSession
in interfacejakarta.jms.QueueConnection
- Throws:
jakarta.jms.JMSException
-
createTopicSession
public jakarta.jms.TopicSession createTopicSession(boolean transacted, int ackMode) throws jakarta.jms.JMSException - Specified by:
createTopicSession
in interfacejakarta.jms.TopicConnection
- Throws:
jakarta.jms.JMSException
-
createSession
public jakarta.jms.Session createSession() throws jakarta.jms.JMSException- Specified by:
createSession
in interfacejakarta.jms.Connection
- Throws:
jakarta.jms.JMSException
-
createSession
public jakarta.jms.Session createSession(int sessionMode) throws jakarta.jms.JMSException - Specified by:
createSession
in interfacejakarta.jms.Connection
- Throws:
jakarta.jms.JMSException
-
createSession
public jakarta.jms.Session createSession(boolean transacted, int ackMode) throws jakarta.jms.JMSException - Specified by:
createSession
in interfacejakarta.jms.Connection
- Throws:
jakarta.jms.JMSException
-
onTemporaryQueueCreate
public void onTemporaryQueueCreate(jakarta.jms.TemporaryQueue tempQueue) Description copied from interface:JmsPoolSessionEventListener
Called on successful creation of a new TemporaryQueue.- Specified by:
onTemporaryQueueCreate
in interfaceJmsPoolSessionEventListener
- Parameters:
tempQueue
- The TemporaryQueue just created.
-
onTemporaryTopicCreate
public void onTemporaryTopicCreate(jakarta.jms.TemporaryTopic tempTopic) Description copied from interface:JmsPoolSessionEventListener
Called on successful creation of a new TemporaryTopic.- Specified by:
onTemporaryTopicCreate
in interfaceJmsPoolSessionEventListener
- Parameters:
tempTopic
- The TemporaryTopic just created.
-
onSessionClosed
Description copied from interface:JmsPoolSessionEventListener
Called when the PooledSession is closed.- Specified by:
onSessionClosed
in interfaceJmsPoolSessionEventListener
- Parameters:
session
- The PooledSession that has been closed.
-
getConnection
public jakarta.jms.Connection getConnection() throws jakarta.jms.JMSException- Throws:
jakarta.jms.JMSException
-
toString
-
cleanupConnectionTemporaryDestinations
protected void cleanupConnectionTemporaryDestinations()Remove all of the temporary destinations created for this connection. This is important since the underlying connection may be reused over a long period of time, accumulating all of the temporary destinations from each use. However, from the perspective of the lifecycle from the client's view, close() closes the connection and, therefore, deletes all of the temporary destinations created. -
cleanupAllLoanedSessions
protected void cleanupAllLoanedSessions()The PooledSession tracks all Sessions that it created and now we close them. Closing the PooledSession will return the internal Session to the Pool of Session after cleaning up all the resources that the Session had allocated for this PooledConnection. -
getNumSessions
public int getNumSessions() throws jakarta.jms.JMSException- Returns:
- the total number of Pooled session including idle sessions that are not currently loaned out to any client.
- Throws:
jakarta.jms.JMSException
- if the connection has been closed.
-
getNumActiveSessions
public int getNumActiveSessions() throws jakarta.jms.JMSException- Returns:
- the number of Sessions that are currently checked out of this Connection's session pool.
- Throws:
jakarta.jms.JMSException
- if the connection has been closed.
-
getNumtIdleSessions
public int getNumtIdleSessions() throws jakarta.jms.JMSException- Returns:
- the number of Sessions that are idle in this Connection's sessions pool.
- Throws:
jakarta.jms.JMSException
- if the connection has been closed.
-
checkClosed
protected void checkClosed() throws jakarta.jms.IllegalStateException- Throws:
jakarta.jms.IllegalStateException
-