Package org.jboss.narayana.jta.jms
Class ConnectionManager
java.lang.Object
org.jboss.narayana.jta.jms.ConnectionManager
- Author:
- Gytis Trikleris
-
Constructor Summary
ConstructorsConstructorDescriptionConnectionManager(jakarta.jms.XAConnectionFactory xaConnectionFactory, String user, String pass) -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()Create JMS connection.voidconnectAndAccept(XAResourceConsumer consumer) InvokeXAResourceConsumeraccept method before making sure that JMS connection is available.<T> TconnectAndApply(XAResourceFunction<T> function) InvokeXAResourceFunctionapply method before making sure that JMS connection is available.voidClose current JMS connection.booleanCheck if JMS connection is active.
-
Constructor Details
-
ConnectionManager
-
-
Method Details
-
connectAndAccept
InvokeXAResourceConsumeraccept method before making sure that JMS connection is available. Current connection is used if one is available. If connection is not available, new connection is created before the accept call and closed after it.- Parameters:
consumer-XAResourceConsumerto be executed.- Throws:
XAException- if JMS connection cannot be created.
-
connectAndApply
InvokeXAResourceFunctionapply method before making sure that JMS connection is available. Current connection is used if one is available. If connection is not available, new connection is created before the apply call and closed after it.- Type Parameters:
T- Return type of theXAResourceFunction.- Parameters:
function-XAResourceFunctionto be executed.- Returns:
- The result of
XAResourceFunction. - Throws:
XAException- if JMS connection cannot be created.
-
connect
Create JMS connection.- Throws:
XAException- if JMS connection cannot be created.
-
disconnect
public void disconnect()Close current JMS connection. -
isConnected
public boolean isConnected()Check if JMS connection is active.- Returns:
trueif JMS connection is active.
-