Class ActiveMQConnection
- java.lang.Object
-
- org.apache.activemq.artemis.jms.client.ActiveMQConnectionForContextImpl
-
- org.apache.activemq.artemis.jms.client.ActiveMQConnection
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,javax.jms.Connection
,javax.jms.QueueConnection
,javax.jms.TopicConnection
,ActiveMQConnectionForContext
- Direct Known Subclasses:
ActiveMQXAConnection
public class ActiveMQConnection extends ActiveMQConnectionForContextImpl implements javax.jms.TopicConnection, javax.jms.QueueConnection
ActiveMQ Artemis implementation of a JMS Connection.The flat implementation of
TopicConnection
andQueueConnection
is per design, following the common usage of these as one flat API in JMS 1.1.
-
-
Field Summary
Fields Modifier and Type Field Description static org.apache.activemq.artemis.api.core.SimpleString
CONNECTION_ID_PROPERTY_NAME
static java.lang.String
EXCEPTION_DISCONNECT
static java.lang.String
EXCEPTION_FAILOVER
static int
TYPE_GENERIC_CONNECTION
static int
TYPE_QUEUE_CONNECTION
static int
TYPE_TOPIC_CONNECTION
-
Fields inherited from class org.apache.activemq.artemis.jms.client.ActiveMQConnectionForContextImpl
threadAwareContext
-
-
Constructor Summary
Constructors Constructor Description ActiveMQConnection(ConnectionFactoryOptions options, java.lang.String username, java.lang.String password, int connectionType, java.lang.String clientID, int dupsOKBatchSize, int transactionBatchSize, boolean cacheDestinations, boolean enable1xPrefixes, ClientSessionFactory sessionFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTemporaryQueue(org.apache.activemq.artemis.api.core.SimpleString queueAddress)
void
authorize()
void
authorize(boolean validateClientId)
static int
checkAck(boolean transacted, int acknowledgeMode)
I'm keeping this as static as the same check will be done within RA.protected void
checkClosed()
void
close()
boolean
containsTemporaryQueue(org.apache.activemq.artemis.api.core.SimpleString queueAddress)
protected ActiveMQSession
createAMQSession(boolean isXA, boolean transacted, int acknowledgeMode, ClientSession session, int type)
javax.jms.ConnectionConsumer
createConnectionConsumer(javax.jms.Destination destination, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
javax.jms.ConnectionConsumer
createConnectionConsumer(javax.jms.Queue queue, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
javax.jms.ConnectionConsumer
createConnectionConsumer(javax.jms.Topic topic, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
javax.jms.ConnectionConsumer
createDurableConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
javax.jms.Session
createNonXAQueueSession(boolean transacted, int acknowledgeMode)
This internal method serves basically the Resource Adapter.javax.jms.Session
createNonXASession(boolean transacted, int acknowledgeMode)
This internal method serves basically the Resource Adapter.javax.jms.Session
createNonXATopicSession(boolean transacted, int acknowledgeMode)
This internal method serves basically the Resource Adapter.javax.jms.QueueSession
createQueueSession(boolean transacted, int acknowledgeMode)
javax.jms.Session
createSession()
javax.jms.Session
createSession(boolean transacted, int acknowledgeMode)
javax.jms.Session
createSession(int sessionMode)
protected ActiveMQSession
createSessionInternal(boolean isXA, boolean transacted, int acknowledgeMode, int type)
javax.jms.ConnectionConsumer
createSharedConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
javax.jms.ConnectionConsumer
createSharedDurableConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
javax.jms.TopicSession
createTopicSession(boolean transacted, int acknowledgeMode)
java.lang.String
getClientID()
java.lang.String
getDeserializationBlackList()
java.lang.String
getDeserializationWhiteList()
javax.jms.ExceptionListener
getExceptionListener()
FailoverEventListener
getFailoverListener()
ClientSession
getInitialSession()
javax.jms.ConnectionMetaData
getMetaData()
ClientSessionFactory
getSessionFactory()
org.apache.activemq.artemis.api.core.SimpleString
getUID()
boolean
hasNoLocal()
boolean
isStarted()
protected boolean
isXA()
void
removeSession(ActiveMQSession session)
void
removeTemporaryQueue(org.apache.activemq.artemis.api.core.SimpleString queueAddress)
void
setClientID(java.lang.String clientID)
void
setExceptionListener(javax.jms.ExceptionListener listener)
void
setFailoverListener(FailoverEventListener listener)
Sets a FailureListener for the session which is notified if a failure occurs on the session.void
setHasNoLocal()
void
setReference(ActiveMQConnectionFactory factory)
void
signalStopToAllSessions()
void
start()
void
stop()
-
Methods inherited from class org.apache.activemq.artemis.jms.client.ActiveMQConnectionForContextImpl
closeFromContext, createContext, createXAContext, getThreadAwareContext, incrementRefCounter
-
-
-
-
Field Detail
-
TYPE_GENERIC_CONNECTION
public static final int TYPE_GENERIC_CONNECTION
- See Also:
- Constant Field Values
-
TYPE_QUEUE_CONNECTION
public static final int TYPE_QUEUE_CONNECTION
- See Also:
- Constant Field Values
-
TYPE_TOPIC_CONNECTION
public static final int TYPE_TOPIC_CONNECTION
- See Also:
- Constant Field Values
-
EXCEPTION_FAILOVER
public static final java.lang.String EXCEPTION_FAILOVER
- See Also:
- Constant Field Values
-
EXCEPTION_DISCONNECT
public static final java.lang.String EXCEPTION_DISCONNECT
- See Also:
- Constant Field Values
-
CONNECTION_ID_PROPERTY_NAME
public static final org.apache.activemq.artemis.api.core.SimpleString CONNECTION_ID_PROPERTY_NAME
-
-
Constructor Detail
-
ActiveMQConnection
public ActiveMQConnection(ConnectionFactoryOptions options, java.lang.String username, java.lang.String password, int connectionType, java.lang.String clientID, int dupsOKBatchSize, int transactionBatchSize, boolean cacheDestinations, boolean enable1xPrefixes, ClientSessionFactory sessionFactory)
-
-
Method Detail
-
createNonXASession
public javax.jms.Session createNonXASession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
This internal method serves basically the Resource Adapter. The resource adapter plays with an XASession and a non XASession. When there is no enlisted transaction, the EE specification mandates that the commit should be done as if it was a nonXA Session (i.e. SessionTransacted). For that reason we have this method to force that nonXASession, since the JMS Javadoc mandates createSession to return a XASession.- Throws:
javax.jms.JMSException
-
createNonXATopicSession
public javax.jms.Session createNonXATopicSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
This internal method serves basically the Resource Adapter. The resource adapter plays with an XASession and a non XASession. When there is no enlisted transaction, the EE specification mandates that the commit should be done as if it was a nonXA Session (i.e. SessionTransacted). For that reason we have this method to force that nonXASession, since the JMS Javadoc mandates createSession to return a XASession.- Throws:
javax.jms.JMSException
-
createNonXAQueueSession
public javax.jms.Session createNonXAQueueSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
This internal method serves basically the Resource Adapter. The resource adapter plays with an XASession and a non XASession. When there is no enlisted transaction, the EE specification mandates that the commit should be done as if it was a nonXA Session (i.e. SessionTransacted). For that reason we have this method to force that nonXASession, since the JMS Javadoc mandates createSession to return a XASession.- Throws:
javax.jms.JMSException
-
createSession
public javax.jms.Session createSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
- Specified by:
createSession
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
getClientID
public java.lang.String getClientID() throws javax.jms.JMSException
- Specified by:
getClientID
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
setClientID
public void setClientID(java.lang.String clientID) throws javax.jms.JMSException
- Specified by:
setClientID
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
getMetaData
public javax.jms.ConnectionMetaData getMetaData() throws javax.jms.JMSException
- Specified by:
getMetaData
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
getExceptionListener
public javax.jms.ExceptionListener getExceptionListener() throws javax.jms.JMSException
- Specified by:
getExceptionListener
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
setExceptionListener
public void setExceptionListener(javax.jms.ExceptionListener listener) throws javax.jms.JMSException
- Specified by:
setExceptionListener
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
start
public void start() throws javax.jms.JMSException
- Specified by:
start
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
signalStopToAllSessions
public void signalStopToAllSessions()
-
stop
public void stop() throws javax.jms.JMSException
- Specified by:
stop
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
close
public final void close() throws javax.jms.JMSException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
createConnectionConsumer
public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
- Specified by:
createConnectionConsumer
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
createDurableConnectionConsumer
public javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
- Specified by:
createDurableConnectionConsumer
in interfacejavax.jms.Connection
- Specified by:
createDurableConnectionConsumer
in interfacejavax.jms.TopicConnection
- Throws:
javax.jms.JMSException
-
createSession
public javax.jms.Session createSession(int sessionMode) throws javax.jms.JMSException
- Specified by:
createSession
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
createSession
public javax.jms.Session createSession() throws javax.jms.JMSException
- Specified by:
createSession
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
createQueueSession
public javax.jms.QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
- Specified by:
createQueueSession
in interfacejavax.jms.QueueConnection
- Throws:
javax.jms.JMSException
-
checkAck
public static int checkAck(boolean transacted, int acknowledgeMode)
I'm keeping this as static as the same check will be done within RA. This is to conform with TCK Tests where we must return ackMode exactly as they want if transacted=false
-
createConnectionConsumer
public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Queue queue, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
- Specified by:
createConnectionConsumer
in interfacejavax.jms.QueueConnection
- Throws:
javax.jms.JMSException
-
createTopicSession
public javax.jms.TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
- Specified by:
createTopicSession
in interfacejavax.jms.TopicConnection
- Throws:
javax.jms.JMSException
-
createConnectionConsumer
public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Topic topic, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
- Specified by:
createConnectionConsumer
in interfacejavax.jms.TopicConnection
- Throws:
javax.jms.JMSException
-
createSharedConnectionConsumer
public javax.jms.ConnectionConsumer createSharedConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
- Specified by:
createSharedConnectionConsumer
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
createSharedDurableConnectionConsumer
public javax.jms.ConnectionConsumer createSharedDurableConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
- Specified by:
createSharedDurableConnectionConsumer
in interfacejavax.jms.Connection
- Throws:
javax.jms.JMSException
-
setFailoverListener
public void setFailoverListener(FailoverEventListener listener) throws javax.jms.JMSException
Sets a FailureListener for the session which is notified if a failure occurs on the session.- Parameters:
listener
- the listener to add- Throws:
javax.jms.JMSException
-
getFailoverListener
public FailoverEventListener getFailoverListener() throws javax.jms.JMSException
- Returns:
FailoverEventListener
the current failover event listener for this connection- Throws:
javax.jms.JMSException
-
addTemporaryQueue
public void addTemporaryQueue(org.apache.activemq.artemis.api.core.SimpleString queueAddress)
-
removeTemporaryQueue
public void removeTemporaryQueue(org.apache.activemq.artemis.api.core.SimpleString queueAddress)
-
containsTemporaryQueue
public boolean containsTemporaryQueue(org.apache.activemq.artemis.api.core.SimpleString queueAddress)
-
hasNoLocal
public boolean hasNoLocal()
-
setHasNoLocal
public void setHasNoLocal()
-
getUID
public org.apache.activemq.artemis.api.core.SimpleString getUID()
-
removeSession
public void removeSession(ActiveMQSession session)
-
getInitialSession
public ClientSession getInitialSession()
-
isXA
protected boolean isXA()
-
createSessionInternal
protected final ActiveMQSession createSessionInternal(boolean isXA, boolean transacted, int acknowledgeMode, int type) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
getSessionFactory
public ClientSessionFactory getSessionFactory()
-
createAMQSession
protected ActiveMQSession createAMQSession(boolean isXA, boolean transacted, int acknowledgeMode, ClientSession session, int type)
- Parameters:
transacted
-acknowledgeMode
-session
-type
-- Returns:
-
checkClosed
protected final void checkClosed() throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
authorize
public void authorize() throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
authorize
public void authorize(boolean validateClientId) throws javax.jms.JMSException
- Throws:
javax.jms.JMSException
-
setReference
public void setReference(ActiveMQConnectionFactory factory)
-
isStarted
public boolean isStarted()
-
getDeserializationBlackList
public java.lang.String getDeserializationBlackList()
-
getDeserializationWhiteList
public java.lang.String getDeserializationWhiteList()
-
-