Package org.jboss.narayana.jta.jms
Class ConnectionManager
- java.lang.Object
-
- org.jboss.narayana.jta.jms.ConnectionManager
-
public class ConnectionManager extends Object
- Author:
- Gytis Trikleris
-
-
Constructor Summary
Constructors Constructor Description ConnectionManager(jakarta.jms.XAConnectionFactory xaConnectionFactory, String user, String pass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect()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.voiddisconnect()Close current JMS connection.booleanisConnected()Check if JMS connection is active.
-
-
-
Method Detail
-
connectAndAccept
public void connectAndAccept(XAResourceConsumer consumer) throws XAException
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
public <T> T connectAndApply(XAResourceFunction<T> function) throws XAException
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
public void connect() throws XAExceptionCreate 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.
-
-