Package org.messaginghub.pooled.jms
Class JmsPoolXAConnectionFactory
java.lang.Object
org.messaginghub.pooled.jms.JmsPoolConnectionFactory
org.messaginghub.pooled.jms.JmsPoolXAConnectionFactory
- All Implemented Interfaces:
jakarta.jms.ConnectionFactory
,jakarta.jms.QueueConnectionFactory
,jakarta.jms.TopicConnectionFactory
,jakarta.jms.XAConnectionFactory
,Serializable
,ObjectFactory
- Direct Known Subclasses:
JmsPoolJcaConnectionFactory
public class JmsPoolXAConnectionFactory
extends JmsPoolConnectionFactory
implements ObjectFactory, Serializable, jakarta.jms.XAConnectionFactory
A pooled connection factory that automatically enlists sessions in the
current active XA transaction if any.
- See Also:
-
Field Summary
Fields inherited from class org.messaginghub.pooled.jms.JmsPoolConnectionFactory
connectionFactory, DEFAULT_MAX_CONNECTIONS, DEFAULT_MAX_SESSIONS_PER_CONNECTION, stopped
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected PooledXAConnection
createPooledConnection
(jakarta.jms.Connection connection) Delegate that creates each instance of an ConnectionPool object.protected jakarta.jms.XAConnection
Given aPooledConnectionKey
create a JMSConnection
using the configuration from the key and the assigned JMSConnectionFactory
instance.protected jakarta.jms.XAJMSContext
createProviderContext
(String username, String password, int sessionMode) Create a newJMSContext
using the provided credentials and Session modejakarta.jms.XAConnection
jakarta.jms.XAConnection
createXAConnection
(String userName, String password) jakarta.jms.XAJMSContext
jakarta.jms.XAJMSContext
createXAContext
(String userName, String password) getObjectInstance
(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) jakarta.transaction.TransactionManager
boolean
protected JmsPoolXAJMSContext
newPooledConnectionContext
(JmsPoolConnection connection, int sessionMode) Allows subclasses to create an appropriate JmsPoolJMSContext wrapper for the newly create JMSContext such as one that provides support for XA Transactions.void
setConnectionFactory
(Object toUse) Sets the ConnectionFactory used to create new pooled Connections.void
setTmFromJndi
(boolean tmFromJndi) Allow transaction manager resolution from JNDI (ee deployment)void
setTmJndiName
(String tmJndiName) void
setTransactionManager
(jakarta.transaction.TransactionManager transactionManager) Methods inherited from class org.messaginghub.pooled.jms.JmsPoolConnectionFactory
clear, createConnection, createConnection, createContext, createContext, createContext, createContext, createQueueConnection, createQueueConnection, createTopicConnection, createTopicConnection, getBlockIfSessionPoolIsFullTimeout, getConnectionCheckInterval, getConnectionFactory, getConnectionIdleTimeout, getConnectionsPool, getExplicitProducerCacheSize, getMaxConnections, getMaxIdleSessionsPerConnection, getMaxSessionsPerConnection, getNumConnections, initConnectionsPool, isBlockIfSessionPoolIsFull, isUseAnonymousProducers, isUseProviderJMSContext, newPooledConnectionWrapper, populateProperties, setBlockIfSessionPoolIsFull, setBlockIfSessionPoolIsFullTimeout, setConnectionCheckInterval, setConnectionIdleTimeout, setExplicitProducerCacheSize, setMaxConnections, setMaxIdleSessionsPerConnection, setMaxSessionsPerConnection, setUseAnonymousProducers, setUseProviderJMSContext, start, stop
-
Constructor Details
-
JmsPoolXAConnectionFactory
public JmsPoolXAConnectionFactory()
-
-
Method Details
-
getTransactionManager
public jakarta.transaction.TransactionManager getTransactionManager() -
setTransactionManager
public void setTransactionManager(jakarta.transaction.TransactionManager transactionManager) -
setConnectionFactory
Description copied from class:JmsPoolConnectionFactory
Sets the ConnectionFactory used to create new pooled Connections.Updates to this value do not affect Connections that were previously created and placed into the pool. In order to allocate new Connections based off this new ConnectionFactory it is first necessary to
JmsPoolConnectionFactory.clear()
the pooled Connections.- Overrides:
setConnectionFactory
in classJmsPoolConnectionFactory
- Parameters:
toUse
- The factory to use to create pooled Connections.
-
createProviderConnection
protected jakarta.jms.XAConnection createProviderConnection(PooledConnectionKey key) throws jakarta.jms.JMSException Description copied from class:JmsPoolConnectionFactory
Given aPooledConnectionKey
create a JMSConnection
using the configuration from the key and the assigned JMSConnectionFactory
instance.- Overrides:
createProviderConnection
in classJmsPoolConnectionFactory
- Parameters:
key
- ThePooledSessionKey
to use as configuration for the new JMS Connection.- Returns:
- a new JMS Connection created using the configured JMS ConnectionFactory.
- Throws:
jakarta.jms.JMSException
- if an error occurs while creating the new JMS Connection.
-
createProviderContext
protected jakarta.jms.XAJMSContext createProviderContext(String username, String password, int sessionMode) Description copied from class:JmsPoolConnectionFactory
Create a newJMSContext
using the provided credentials and Session mode- Overrides:
createProviderContext
in classJmsPoolConnectionFactory
- Parameters:
username
- The user name to use when creating the context.password
- The password to use when creating the context.sessionMode
- The session mode to use when creating the context.- Returns:
- a new JMSContext created using the given configuration data..
-
createPooledConnection
Description copied from class:JmsPoolConnectionFactory
Delegate that creates each instance of an ConnectionPool object. Subclasses can override this method to customize the type of connection pool returned.- Overrides:
createPooledConnection
in classJmsPoolConnectionFactory
- Parameters:
connection
- The connection that is being added into the pool.- Returns:
- instance of a new ConnectionPool.
-
newPooledConnectionContext
protected JmsPoolXAJMSContext newPooledConnectionContext(JmsPoolConnection connection, int sessionMode) Description copied from class:JmsPoolConnectionFactory
Allows subclasses to create an appropriate JmsPoolJMSContext wrapper for the newly create JMSContext such as one that provides support for XA Transactions.- Overrides:
newPooledConnectionContext
in classJmsPoolConnectionFactory
- Parameters:
connection
- TheJmsPoolConnection
to use in the JMSContext wrapper.sessionMode
- The JMS Session acknowledgement mode to use in theJMSContext
- Returns:
- a new
JmsPoolJMSContext
that wraps the givenJmsPoolConnection
-
getObjectInstance
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception- Specified by:
getObjectInstance
in interfaceObjectFactory
- Throws:
Exception
-
getTmJndiName
-
setTmJndiName
-
isTmFromJndi
public boolean isTmFromJndi() -
setTmFromJndi
public void setTmFromJndi(boolean tmFromJndi) Allow transaction manager resolution from JNDI (ee deployment)- Parameters:
tmFromJndi
- controls if TXN manager resolution is from JNDI
-
createXAConnection
public jakarta.jms.XAConnection createXAConnection() throws jakarta.jms.JMSException- Specified by:
createXAConnection
in interfacejakarta.jms.XAConnectionFactory
- Throws:
jakarta.jms.JMSException
-
createXAConnection
public jakarta.jms.XAConnection createXAConnection(String userName, String password) throws jakarta.jms.JMSException - Specified by:
createXAConnection
in interfacejakarta.jms.XAConnectionFactory
- Throws:
jakarta.jms.JMSException
-
createXAContext
public jakarta.jms.XAJMSContext createXAContext()- Specified by:
createXAContext
in interfacejakarta.jms.XAConnectionFactory
-
createXAContext
- Specified by:
createXAContext
in interfacejakarta.jms.XAConnectionFactory
-