Class ThreadContextWorkflow

All Implemented Interfaces:
AdaptrisComponent, AdaptrisMessageListener, ComponentLifecycle, ComponentLifecycleExtension, ConfigComment, EventHandlerAware, StateManagedComponent, Workflow

@ComponentProfile(summary="Workflow that executes within the current thread context.", tag="workflow", since="3.12.0") public class ThreadContextWorkflow extends WorkflowWithObjectPool
Workflow that executes services in the current thread.

This is different to StandardWorkflow in the sense that it does not synchronize on the onAdaptrisMessage() method and processes the message in the same thread as the caller. This is useful if you have a consumer that may be triggered by multiple threads (e.g. Jetty or JMS) but you don't want to use PoolingWorkflow. It is probably of little or no benefit where the consumer is a polling implementation.

Since services cannot be guaranteed to be thread-safe; it maintains an internal object pool that is independently sizeable.

In the adapter configuration file this class is aliased as thread-context-workflow which is the preferred alternative to the fully qualified classname when building your configuration.

  • Constructor Details

    • ThreadContextWorkflow

      public ThreadContextWorkflow()
  • Method Details

    • onMessage

      protected void onMessage(AdaptrisMessage msg)
      Specified by:
      onMessage in class WorkflowWithObjectPool
    • friendlyName

      public String friendlyName()
      Description copied from interface: AdaptrisMessageListener
      Get the friendly name for this component.
      Specified by:
      friendlyName in interface AdaptrisMessageListener
      Overrides:
      friendlyName in class WorkflowImp
      Returns:
      the friendly name.
    • initialiseWorkflow

      protected void initialiseWorkflow() throws CoreException
      Description copied from class: WorkflowImp
      Initialise the workflow.
      Specified by:
      initialiseWorkflow in class WorkflowImp
      Throws:
      CoreException - encapsulating any underlying Exception
    • startWorkflow

      protected void startWorkflow() throws CoreException
      Description copied from class: WorkflowImp
      Start the workflow.
      Specified by:
      startWorkflow in class WorkflowImp
      Throws:
      CoreException - encapsulating any underlying Exception
      See Also:
    • stopWorkflow

      protected void stopWorkflow()
      Description copied from class: WorkflowImp
      Stop the workflow.
      Specified by:
      stopWorkflow in class WorkflowImp
    • closeWorkflow

      protected void closeWorkflow()
      Description copied from class: WorkflowImp
      Close the workflow.
      Specified by:
      closeWorkflow in class WorkflowImp
    • getAddCurrentThreadName

      public Boolean getAddCurrentThreadName()
      Append the current thread name to any generated friendly name.

      If you are using this workflow, then there may be thread naming in play (by jetty or otherwise) which you may wish to preserve. Setting this flag to true means that the current thread name from Thread.currentThread().currentName() is appended to any generated friendly name.

      It defaults to true if not explicitly configured

    • setAddCurrentThreadName

      public void setAddCurrentThreadName(Boolean addCurrentThreadName)
      Append the current thread name to any generated friendly name.

      If you are using this workflow, then there may be thread naming in play (by jetty or otherwise) which you may wish to preserve. Setting this flag to true means that the current thread name from Thread.currentThread().currentName() is appended to any generated friendly name.

      It defaults to true if not explicitly configured

    • getAdditionalDebug

      public Boolean getAdditionalDebug()
      Log the internal object pool state.
    • setAdditionalDebug

      public void setAdditionalDebug(Boolean additionalDebug)
      Log the internal object pool state.