Class ActiveMQRAJMSContext
- All Implemented Interfaces:
JMSContext,AutoCloseable
- Direct Known Subclasses:
ActiveMQRAXAJMSContext
-
Field Summary
Fields inherited from interface jakarta.jms.JMSContext
AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE, SESSION_TRANSACTED -
Constructor Summary
ConstructorsConstructorDescriptionActiveMQRAJMSContext(ActiveMQConnectionForContext connection, int ackMode, ThreadAwareContext threadAwareContext) ActiveMQRAJMSContext(ActiveMQConnectionForContext connection, ThreadAwareContext threadAwareContext) -
Method Summary
Modifier and TypeMethodDescriptioncreateContext(int sessionMode) Creates a newJMSContextwith the specified session mode using the same connection as thisJMSContextand creating a new session.voidsetClientID(String clientID) Sets the client identifier for the JMSContext's connection.voidsetExceptionListener(ExceptionListener listener) Sets an exception listener for the JMSContext's connection.voidstop()Temporarily stops the delivery of incoming messages by the JMSContext's connection.Methods inherited from class org.apache.activemq.artemis.jms.client.ActiveMQJMSContext
acknowledge, close, commit, createBrowser, createBrowser, createBytesMessage, createConsumer, createConsumer, createConsumer, createDurableConsumer, createDurableConsumer, createMapMessage, createMessage, createObjectMessage, createObjectMessage, createProducer, createQueue, createSharedConsumer, createSharedConsumer, createSharedDurableConsumer, createSharedDurableConsumer, createStreamMessage, createTemporaryQueue, createTemporaryTopic, createTextMessage, createTextMessage, createTopic, getAutoStart, getClientID, getContext, getExceptionListener, getMetaData, getSession, getSessionMode, getThreadAwareContext, getTransacted, getUsedSession, getXAResource, recover, rollback, setAutoStart, start, unsubscribe
-
Constructor Details
-
ActiveMQRAJMSContext
public ActiveMQRAJMSContext(ActiveMQConnectionForContext connection, int ackMode, ThreadAwareContext threadAwareContext) -
ActiveMQRAJMSContext
public ActiveMQRAJMSContext(ActiveMQConnectionForContext connection, ThreadAwareContext threadAwareContext)
-
-
Method Details
-
createContext
Description copied from interface:JMSContextCreates a newJMSContextwith the specified session mode using the same connection as thisJMSContextand creating a new session.This method does not start the connection. If the connection has not already been started then it will be automatically started when a
JMSConsumeris created on any of theJMSContextobjects for that connection.- If
sessionModeis set toJMSContext.SESSION_TRANSACTEDthen the session will use a local transaction which may subsequently be committed or rolled back by calling theJMSContext'scommitorrollbackmethods. - If
sessionModeis set to any ofJMSContext.CLIENT_ACKNOWLEDGE,JMSContext.AUTO_ACKNOWLEDGEorJMSContext.DUPS_OK_ACKNOWLEDGE. then the session will be non-transacted and messages received by this session will be acknowledged according to the value ofsessionMode. For a definition of the meaning of these acknowledgement modes see the links below.
This method must not be used by applications running in the Jakarta EE web or EJB containers because doing so would violate the restriction that such an application must not attempt to create more than one active (not closed)
Sessionobject per connection. If this method is called in a Jakarta EE web or EJB container then aJMSRuntimeExceptionwill be thrown.- Specified by:
createContextin interfaceJMSContext- Overrides:
createContextin classActiveMQJMSContext- Parameters:
sessionMode- indicates which of four possible session modes will be used. The permitted values areJMSContext.SESSION_TRANSACTED,JMSContext.CLIENT_ACKNOWLEDGE,JMSContext.AUTO_ACKNOWLEDGEandJMSContext.DUPS_OK_ACKNOWLEDGE.- Returns:
- a newly created JMSContext
- See Also:
-
JMSContext.SESSION_TRANSACTEDJMSContext.CLIENT_ACKNOWLEDGEJMSContext.AUTO_ACKNOWLEDGEJMSContext.DUPS_OK_ACKNOWLEDGEConnectionFactory.createContext()ConnectionFactory.createContext(int)ConnectionFactory.createContext(java.lang.String, java.lang.String)ConnectionFactory.createContext(java.lang.String, java.lang.String, int)JMSContext.createContext(int)
- If
-
stop
public void stop()Description copied from interface:JMSContextTemporarily stops the delivery of incoming messages by the JMSContext's connection. Delivery can be restarted using thestartmethod. When the connection is stopped, delivery to all the connection's message consumers is inhibited: synchronous receives block, and messages are not delivered to message listeners.Stopping a connection has no effect on its ability to send messages. A call to
stopon a connection that has already been stopped is ignored.A call to
stopmust not return until delivery of messages has paused. This means that a client can rely on the fact that none of its message listeners will be called and that all threads of control waiting forreceivecalls to return will not return with a message until the connection is restarted. The receive timers for a stopped connection continue to advance, so receives may time out while the connection is stopped.If message listeners are running when
stopis invoked, thestopcall must wait until all of them have returned before it may return. While these message listeners are completing, they must have the full services of the connection available to them.However if the stop method is called from a message listener on its own
JMSContext, or any otherJMSContextthat uses the same connection, then it will either fail and throw ajakarta.jms.IllegalStateRuntimeException, or it will succeed and stop the connection, blocking until all other message listeners that may have been running have returned.Since two alternative behaviors are permitted in this case, applications should avoid calling
stopfrom a message listener on its ownJMSContext, or any otherJMSContextthat uses the same connection, because this is not portable.For the avoidance of doubt, if an exception listener for the JMSContext's connection is running when
stopis invoked, there is no requirement for thestopcall to wait until the exception listener has returned before it may return.This method must not be used in a Jakarta EE web or EJB application. Doing so may cause a
JMSRuntimeExceptionto be thrown though this is not guaranteed.This method must not be used if the
JMSContextis container-managed (injected). Doing so will cause aIllegalStateRuntimeExceptionto be thrown.- Specified by:
stopin interfaceJMSContext- Overrides:
stopin classActiveMQJMSContext- See Also:
-
setClientID
Description copied from interface:JMSContextSets the client identifier for the JMSContext's connection.The preferred way to assign a Jakarta Messaging client's client identifier is for it to be configured in a client-specific
ConnectionFactoryobject and transparently assigned to theConnectionobject it creates.Alternatively, a client can set the client identifier for the JMSContext's connection using a provider-specific value. The facility to set its client identifier explicitly is not a mechanism for overriding the identifier that has been administratively configured. It is provided for the case where no administratively specified identifier exists. If one does exist, an attempt to change it by setting it must throw an
IllegalStateRuntimeException. If a client sets the client identifier explicitly, it must do so immediately after it creates the JMSContext and before any other action on the JMSContext is taken. After this point, setting the client identifier is a programming error that should throw anIllegalStateRuntimeException.The purpose of the client identifier is to associate the JMSContext's connection and its objects with a state maintained on behalf of the client by a provider. The only such state identified by the Jakarta Messaging API is that required to support durable subscriptions.
If another connection with the same
clientIDis already running when this method is called, the Jakarta Messaging provider should detect the duplicate ID and throw anInvalidClientIDException.This method must not be used in a Jakarta EE web or EJB application. Doing so may cause a
JMSRuntimeExceptionto be thrown though this is not guaranteed.This method must not be used if the
JMSContextis container-managed (injected). Doing so will cause aIllegalStateRuntimeExceptionto be thrown.- Specified by:
setClientIDin interfaceJMSContext- Overrides:
setClientIDin classActiveMQJMSContext- Parameters:
clientID- the unique client identifier
-
setExceptionListener
Description copied from interface:JMSContextSets an exception listener for the JMSContext's connection.If a Jakarta Messaging provider detects a serious problem with a connection, it informs the connection's
ExceptionListener, if one has been registered. It does this by calling the listener'sonExceptionmethod, passing it aJMSRuntimeExceptionobject describing the problem.An exception listener allows a client to be notified of a problem asynchronously. Some connections only consume messages, so they would have no other way to learn their connection has failed.
A connection serializes execution of its
ExceptionListener.A Jakarta Messaging provider should attempt to resolve connection problems itself before it notifies the client of them.
This method must not be used in a Jakarta EE web or EJB application. Doing so may cause a
JMSRuntimeExceptionto be thrown though this is not guaranteed.This method must not be used if the
JMSContextis container-managed (injected). Doing so will cause aIllegalStateRuntimeExceptionto be thrown.- Specified by:
setExceptionListenerin interfaceJMSContext- Overrides:
setExceptionListenerin classActiveMQJMSContext- Parameters:
listener- the exception listener
-