Class ActiveMQRAJMSContext

java.lang.Object
org.apache.activemq.artemis.jms.client.ActiveMQJMSContext
org.apache.activemq.artemis.ra.ActiveMQRAJMSContext
All Implemented Interfaces:
JMSContext, AutoCloseable
Direct Known Subclasses:
ActiveMQRAXAJMSContext

public class ActiveMQRAJMSContext extends ActiveMQJMSContext
  • Constructor Details

  • Method Details

    • createContext

      public JMSContext createContext(int sessionMode)
      Description copied from interface: JMSContext
      Creates a new JMSContext with the specified session mode using the same connection as this JMSContext and 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 JMSConsumer is created on any of the JMSContext objects for that connection.

      • If sessionMode is set to JMSContext.SESSION_TRANSACTED then the session will use a local transaction which may subsequently be committed or rolled back by calling the JMSContext's commit or rollback methods.
      • If sessionMode is set to any of JMSContext.CLIENT_ACKNOWLEDGE, JMSContext.AUTO_ACKNOWLEDGE or JMSContext.DUPS_OK_ACKNOWLEDGE. then the session will be non-transacted and messages received by this session will be acknowledged according to the value of sessionMode. 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) Session object per connection. If this method is called in a Jakarta EE web or EJB container then a JMSRuntimeException will be thrown.

      Specified by:
      createContext in interface JMSContext
      Overrides:
      createContext in class ActiveMQJMSContext
      Parameters:
      sessionMode - indicates which of four possible session modes will be used. The permitted values are JMSContext.SESSION_TRANSACTED, JMSContext.CLIENT_ACKNOWLEDGE, JMSContext.AUTO_ACKNOWLEDGE and JMSContext.DUPS_OK_ACKNOWLEDGE.
      Returns:
      a newly created JMSContext
      See Also:
    • stop

      public void stop()
      Description copied from interface: JMSContext
      Temporarily stops the delivery of incoming messages by the JMSContext's connection. Delivery can be restarted using the start method. 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 stop on a connection that has already been stopped is ignored.

      A call to stop must 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 for receive calls 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 stop is invoked, the stop call 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 other JMSContext that uses the same connection, then it will either fail and throw a jakarta.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 stop from a message listener on its own JMSContext, or any other JMSContext that 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 stop is invoked, there is no requirement for the stop call 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 JMSRuntimeException to be thrown though this is not guaranteed.

      This method must not be used if the JMSContext is container-managed (injected). Doing so will cause a IllegalStateRuntimeException to be thrown.

      Specified by:
      stop in interface JMSContext
      Overrides:
      stop in class ActiveMQJMSContext
      See Also:
    • setClientID

      public void setClientID(String clientID)
      Description copied from interface: JMSContext
      Sets 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 ConnectionFactory object and transparently assigned to the Connection object 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 an IllegalStateRuntimeException.

      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 clientID is already running when this method is called, the Jakarta Messaging provider should detect the duplicate ID and throw an InvalidClientIDException.

      This method must not be used in a Jakarta EE web or EJB application. Doing so may cause a JMSRuntimeException to be thrown though this is not guaranteed.

      This method must not be used if the JMSContext is container-managed (injected). Doing so will cause a IllegalStateRuntimeException to be thrown.

      Specified by:
      setClientID in interface JMSContext
      Overrides:
      setClientID in class ActiveMQJMSContext
      Parameters:
      clientID - the unique client identifier
    • setExceptionListener

      public void setExceptionListener(ExceptionListener listener)
      Description copied from interface: JMSContext
      Sets 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's onException method, passing it a JMSRuntimeException object 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 JMSRuntimeException to be thrown though this is not guaranteed.

      This method must not be used if the JMSContext is container-managed (injected). Doing so will cause a IllegalStateRuntimeException to be thrown.

      Specified by:
      setExceptionListener in interface JMSContext
      Overrides:
      setExceptionListener in class ActiveMQJMSContext
      Parameters:
      listener - the exception listener