Package org.jboss.narayana.jta.jms
Class ConnectionManager
java.lang.Object
org.jboss.narayana.jta.jms.ConnectionManager
- Author:
- Gytis Trikleris
-
Constructor Summary
ConstructorDescriptionConnectionManager
(jakarta.jms.XAConnectionFactory xaConnectionFactory, String user, String pass) -
Method Summary
Modifier and TypeMethodDescriptionvoid
connect()
Create JMS connection.void
connectAndAccept
(XAResourceConsumer consumer) InvokeXAResourceConsumer
accept method before making sure that JMS connection is available.<T> T
connectAndApply
(XAResourceFunction<T> function) InvokeXAResourceFunction
apply method before making sure that JMS connection is available.void
Close current JMS connection.boolean
Check if JMS connection is active.
-
Constructor Details
-
ConnectionManager
-
-
Method Details
-
connectAndAccept
InvokeXAResourceConsumer
accept 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
-XAResourceConsumer
to be executed.- Throws:
XAException
- if JMS connection cannot be created.
-
connectAndApply
InvokeXAResourceFunction
apply 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
-XAResourceFunction
to 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:
true
if JMS connection is active.
-