org.apache.activemq.artemis.jms.client

## Class ThreadAwareContext

- java.lang.Object
- - org.apache.activemq.artemis.jms.client.ThreadAwareContext

-     public class ThreadAwareContext
      extends Object

  Restricts what can be called on context passed in wrapped CompletionListener.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ThreadAwareContext()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `assertNotCompletionListenerThread()` Asserts a `CompletionListener` is not calling from its own `Connection` or from a `MessageProducer` .
    `void` | `assertNotCompletionListenerThreadRuntime()` Asserts a `CompletionListener` is not calling from its own `JMSContext`.
    `void` | `assertNotMessageListenerThread()` Asserts a `MessageListener` is not calling from its own `Connection` or `MessageConsumer`.
    `void` | `assertNotMessageListenerThreadRuntime()` Asserts a `MessageListener` is not calling from its own `JMSContext`.
    `void` | `clearCurrentThread(boolean isCompletionListener)` Clear current thread from the context
    `void` | `setCurrentThread(boolean isCompletionListener)` Sets current thread to the context

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ThreadAwareContext

          public ThreadAwareContext()

  - ### Method Detail

    - #### setCurrentThread

          public void setCurrentThread(boolean isCompletionListener)

      Sets current thread to the context

      Meant to inform an JMSContext which is the thread that CANNOT call some of its methods.

      Parameters:
        `isCompletionListener` - : indicating whether current thread is from CompletionListener or from MessageListener.

    - #### clearCurrentThread

          public void clearCurrentThread(boolean isCompletionListener)

      Clear current thread from the context
      Parameters:
        `isCompletionListener` - : indicating whether current thread is from CompletionListener or from MessageListener.

    - #### assertNotCompletionListenerThreadRuntime

          public void assertNotCompletionListenerThreadRuntime()

      Asserts a `CompletionListener` is not calling from its own `JMSContext`.

      Note that the code must work without any need for further synchronization, as there is the requirement that only one CompletionListener be called at a time. In other words, CompletionListener calling is single-threaded.

      See Also:
        `JMSContext.close()`, `JMSContext.stop()`, `JMSContext.commit()`, `JMSContext.rollback()`

    - #### assertNotCompletionListenerThread

          public void assertNotCompletionListenerThread()
                                                 throws javax.jms.IllegalStateException

      Asserts a `CompletionListener` is not calling from its own `Connection` or from a `MessageProducer` .

      Note that the code must work without any need for further synchronization, as there is the requirement that only one CompletionListener be called at a time. In other words, CompletionListener calling is single-threaded.

      Throws:
        `javax.jms.IllegalStateException`
      See Also:
        `Connection.close()`, `MessageProducer.close()`

    - #### assertNotMessageListenerThreadRuntime

          public void assertNotMessageListenerThreadRuntime()

      Asserts a `MessageListener` is not calling from its own `JMSContext`.

      Note that the code must work without any need for further synchronization, as there is the requirement that only one MessageListener be called at a time. In other words, MessageListener calling is single-threaded.

      See Also:
        `JMSContext.close()`, `JMSContext.stop()`

    - #### assertNotMessageListenerThread

          public void assertNotMessageListenerThread()
                                              throws javax.jms.IllegalStateException

      Asserts a `MessageListener` is not calling from its own `Connection` or `MessageConsumer`.

      Note that the code must work without any need for further synchronization, as there is the requirement that only one MessageListener be called at a time. In other words, MessageListener calling is single-threaded.

      Throws:
        `javax.jms.IllegalStateException`
      See Also:
        `Connection.close()`, `MessageConsumer.close()`

Copyright © 2017. All rights reserved.