Package org.jboss.narayana.jta.jms
Class ConnectionManager
- java.lang.Object
-
- org.jboss.narayana.jta.jms.ConnectionManager
-
public class ConnectionManager extends java.lang.Object- Author:
- Gytis Trikleris
-
-
Constructor Summary
Constructors Constructor Description ConnectionManager(javax.jms.XAConnectionFactory xaConnectionFactory, java.lang.String user, java.lang.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 javax.transaction.xa.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:
javax.transaction.xa.XAException- if JMS connection cannot be created.
-
connectAndApply
public <T> T connectAndApply(XAResourceFunction<T> function) throws javax.transaction.xa.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:
javax.transaction.xa.XAException- if JMS connection cannot be created.
-
connect
public void connect() throws javax.transaction.xa.XAExceptionCreate JMS connection.- Throws:
javax.transaction.xa.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.
-
-