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
TopicConnectionandQueueConnectionis 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.SimpleStringCONNECTION_ID_PROPERTY_NAMEstatic java.lang.StringEXCEPTION_DISCONNECTstatic java.lang.StringEXCEPTION_FAILOVERstatic intTYPE_GENERIC_CONNECTIONstatic intTYPE_QUEUE_CONNECTIONstatic intTYPE_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 voidaddTemporaryQueue(org.apache.activemq.artemis.api.core.SimpleString queueAddress)voidauthorize()voidauthorize(boolean validateClientId)static intcheckAck(boolean transacted, int acknowledgeMode)I'm keeping this as static as the same check will be done within RA.protected voidcheckClosed()voidclose()booleancontainsTemporaryQueue(org.apache.activemq.artemis.api.core.SimpleString queueAddress)protected ActiveMQSessioncreateAMQSession(boolean isXA, boolean transacted, int acknowledgeMode, ClientSession session, int type)javax.jms.ConnectionConsumercreateConnectionConsumer(javax.jms.Destination destination, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)javax.jms.ConnectionConsumercreateConnectionConsumer(javax.jms.Queue queue, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)javax.jms.ConnectionConsumercreateConnectionConsumer(javax.jms.Topic topic, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)javax.jms.ConnectionConsumercreateDurableConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)javax.jms.SessioncreateNonXAQueueSession(boolean transacted, int acknowledgeMode)This internal method serves basically the Resource Adapter.javax.jms.SessioncreateNonXASession(boolean transacted, int acknowledgeMode)This internal method serves basically the Resource Adapter.javax.jms.SessioncreateNonXATopicSession(boolean transacted, int acknowledgeMode)This internal method serves basically the Resource Adapter.javax.jms.QueueSessioncreateQueueSession(boolean transacted, int acknowledgeMode)javax.jms.SessioncreateSession()javax.jms.SessioncreateSession(boolean transacted, int acknowledgeMode)javax.jms.SessioncreateSession(int sessionMode)protected ActiveMQSessioncreateSessionInternal(boolean isXA, boolean transacted, int acknowledgeMode, int type)javax.jms.ConnectionConsumercreateSharedConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)javax.jms.ConnectionConsumercreateSharedDurableConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)javax.jms.TopicSessioncreateTopicSession(boolean transacted, int acknowledgeMode)java.lang.StringgetClientID()java.lang.StringgetDeserializationBlackList()java.lang.StringgetDeserializationWhiteList()javax.jms.ExceptionListenergetExceptionListener()FailoverEventListenergetFailoverListener()ClientSessiongetInitialSession()javax.jms.ConnectionMetaDatagetMetaData()ClientSessionFactorygetSessionFactory()org.apache.activemq.artemis.api.core.SimpleStringgetUID()booleanhasNoLocal()booleanisStarted()protected booleanisXA()voidremoveSession(ActiveMQSession session)voidremoveTemporaryQueue(org.apache.activemq.artemis.api.core.SimpleString queueAddress)voidsetClientID(java.lang.String clientID)voidsetExceptionListener(javax.jms.ExceptionListener listener)voidsetFailoverListener(FailoverEventListener listener)Sets a FailureListener for the session which is notified if a failure occurs on the session.voidsetHasNoLocal()voidsetReference(ActiveMQConnectionFactory factory)voidsignalStopToAllSessions()voidstart()voidstop()-
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.JMSExceptionThis 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.JMSExceptionThis 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.JMSExceptionThis 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:
createSessionin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
getClientID
public java.lang.String getClientID() throws javax.jms.JMSException- Specified by:
getClientIDin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
setClientID
public void setClientID(java.lang.String clientID) throws javax.jms.JMSException- Specified by:
setClientIDin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
getMetaData
public javax.jms.ConnectionMetaData getMetaData() throws javax.jms.JMSException- Specified by:
getMetaDatain interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
getExceptionListener
public javax.jms.ExceptionListener getExceptionListener() throws javax.jms.JMSException- Specified by:
getExceptionListenerin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
setExceptionListener
public void setExceptionListener(javax.jms.ExceptionListener listener) throws javax.jms.JMSException- Specified by:
setExceptionListenerin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
start
public void start() throws javax.jms.JMSException- Specified by:
startin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
signalStopToAllSessions
public void signalStopToAllSessions()
-
stop
public void stop() throws javax.jms.JMSException- Specified by:
stopin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
close
public final void close() throws javax.jms.JMSException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein 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:
createConnectionConsumerin 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:
createDurableConnectionConsumerin interfacejavax.jms.Connection- Specified by:
createDurableConnectionConsumerin interfacejavax.jms.TopicConnection- Throws:
javax.jms.JMSException
-
createSession
public javax.jms.Session createSession(int sessionMode) throws javax.jms.JMSException- Specified by:
createSessionin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
createSession
public javax.jms.Session createSession() throws javax.jms.JMSException- Specified by:
createSessionin interfacejavax.jms.Connection- Throws:
javax.jms.JMSException
-
createQueueSession
public javax.jms.QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException- Specified by:
createQueueSessionin 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:
createConnectionConsumerin interfacejavax.jms.QueueConnection- Throws:
javax.jms.JMSException
-
createTopicSession
public javax.jms.TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException- Specified by:
createTopicSessionin 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:
createConnectionConsumerin 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:
createSharedConnectionConsumerin 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:
createSharedDurableConnectionConsumerin 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:
FailoverEventListenerthe 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()
-
-