Class ThreadContextWorkflow
- java.lang.Object
-
- com.adaptris.core.WorkflowImp
-
- com.adaptris.core.WorkflowWithObjectPool
-
- com.adaptris.core.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 WorkflowWithObjectPoolWorkflow that executes services in the current thread.This is different to
StandardWorkflowin the sense that it does not synchronize on theonAdaptrisMessage()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 usePoolingWorkflow. 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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adaptris.core.WorkflowWithObjectPool
WorkflowWithObjectPool.Worker, WorkflowWithObjectPool.WorkerFactory
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.WorkflowWithObjectPool
DEFAULT_MAX_IDLE, DEFAULT_MAX_POOLSIZE, DEFAULT_MIN_IDLE
-
Fields inherited from class com.adaptris.core.WorkflowImp
eventHandler, log, startTime, stopTime
-
Fields inherited from interface com.adaptris.core.Workflow
PREVIOUS_GUID_KEY, WORKFLOW_ID_KEY
-
-
Constructor Summary
Constructors Constructor Description ThreadContextWorkflow()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcloseWorkflow()Close the workflow.java.lang.StringfriendlyName()Get the friendly name for this component.java.lang.BooleangetAddCurrentThreadName()Append the current thread name to any generated friendly name.java.lang.BooleangetAdditionalDebug()Log the internal object pool state.protected voidinitialiseWorkflow()Initialise the workflow.protected voidonMessage(AdaptrisMessage msg)voidsetAddCurrentThreadName(java.lang.Boolean addCurrentThreadName)Append the current thread name to any generated friendly name.voidsetAdditionalDebug(java.lang.Boolean additionalDebug)Log the internal object pool state.protected voidstartWorkflow()Start the workflow.protected voidstopWorkflow()Stop the workflow.-
Methods inherited from class com.adaptris.core.WorkflowWithObjectPool
checkPoolConfig, cloneServiceCollection, createObjectPool, getInitWaitTime, getMaxIdle, getMinIdle, getPoolSize, initWaitTimeMs, maxIdle, minIdle, onAdaptrisMessage, poolSize, populatePool, preFlightServiceCheck, prepareWorkflow, resubmitMessage, returnObject, setInitWaitTime, setMaxIdle, setMinIdle, setPoolSize
-
Methods inherited from class com.adaptris.core.WorkflowImp
addConsumeLocation, addInterceptor, changeState, channelUnavailableWait, close, copyExceptionHeaders, disableMessageCount, doProduce, getChannelUnavailableWaitInterval, getComments, getConsumer, getDisableDefaultMessageCount, getInterceptors, getMessageErrorHandler, getMessageLogger, getProduceExceptionHandler, getProducer, getSendEvents, getServiceCollection, getUniqueId, handleBadMessage, handleBadMessage, handleChannelUnavailable, handleProduceException, init, lastStartTime, lastStopTime, logSuccess, messageLogger, obtainChannel, obtainWorkflowId, prepare, processingStart, registerActiveMsgErrorHandler, registerChannel, registerEventHandler, requestClose, requestInit, requestStart, requestStop, retrieveActiveMsgErrorHandler, retrieveComponentState, sendEvents, sendMessageLifecycleEvent, setChannelUnavailableWaitInterval, setComments, setConsumer, setDisableDefaultMessageCount, setInterceptors, setMessageErrorHandler, setMessageLogger, setProduceExceptionHandler, setProducer, setSendEvents, setServiceCollection, setUniqueId, start, stop, workflowEnd, workflowStart
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisMessageListener
onAdaptrisMessage, onAdaptrisMessage
-
-
-
-
Method Detail
-
onMessage
protected void onMessage(AdaptrisMessage msg)
- Specified by:
onMessagein classWorkflowWithObjectPool
-
friendlyName
public java.lang.String friendlyName()
Description copied from interface:AdaptrisMessageListenerGet the friendly name for this component.- Specified by:
friendlyNamein interfaceAdaptrisMessageListener- Overrides:
friendlyNamein classWorkflowImp- Returns:
- the friendly name.
-
initialiseWorkflow
protected void initialiseWorkflow() throws CoreExceptionDescription copied from class:WorkflowImpInitialise the workflow.- Specified by:
initialiseWorkflowin classWorkflowImp- Throws:
CoreException- encapsulating any underlying Exception
-
startWorkflow
protected void startWorkflow() throws CoreExceptionDescription copied from class:WorkflowImpStart the workflow.- Specified by:
startWorkflowin classWorkflowImp- Throws:
CoreException- encapsulating any underlying Exception- See Also:
ComponentLifecycle.start()
-
stopWorkflow
protected void stopWorkflow()
Description copied from class:WorkflowImpStop the workflow.- Specified by:
stopWorkflowin classWorkflowImp
-
closeWorkflow
protected void closeWorkflow()
Description copied from class:WorkflowImpClose the workflow.- Specified by:
closeWorkflowin classWorkflowImp
-
getAddCurrentThreadName
public java.lang.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(java.lang.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 java.lang.Boolean getAdditionalDebug()
Log the internal object pool state.
-
setAdditionalDebug
public void setAdditionalDebug(java.lang.Boolean additionalDebug)
Log the internal object pool state.
-
-