public abstract class WorkflowImp extends java.lang.Object implements Workflow
Workflow
.StandardWorkflow
,
PoolingWorkflow
Modifier and Type | Field and Description |
---|---|
protected EventHandler |
eventHandler |
protected org.slf4j.Logger |
log |
protected java.util.Date |
startTime |
protected java.util.Date |
stopTime |
PREVIOUS_GUID_KEY, WORKFLOW_ID_KEY
Constructor and Description |
---|
WorkflowImp()
Creates a new instance with defaults to prevent NullPointerExceptions.
|
Modifier and Type | Method and Description |
---|---|
protected AdaptrisMessage |
addConsumeLocation(AdaptrisMessage msg) |
void |
addInterceptor(WorkflowInterceptor wi) |
void |
changeState(ComponentState s)
Updates the state for the component
ComponentState . |
long |
channelUnavailableWait() |
void |
close()
Close this component.
|
protected abstract void |
closeWorkflow()
Close the workflow.
|
protected AdaptrisMessage |
copyExceptionHeaders(AdaptrisMessage workingCopy,
AdaptrisMessage orig) |
boolean |
disableMessageCount()
Whether or not message-counts should be disabled on this workflow.
|
void |
doProduce(AdaptrisMessage msg)
This method contains the behaviour that varies between standard and request -reply workflows.
|
java.lang.String |
friendlyName()
Get the friendly name for this component.
|
TimeInterval |
getChannelUnavailableWaitInterval()
|
java.lang.String |
getComments() |
AdaptrisMessageConsumer |
getConsumer()
Returns the
AdaptrisMessageConsumer to use. |
java.lang.Boolean |
getDisableDefaultMessageCount() |
java.util.List<WorkflowInterceptor> |
getInterceptors()
Return all the configured interceptors.
|
java.lang.Boolean |
getLogPayload()
Deprecated.
since 3.8.4 use
setMessageLogger(MessageLogger) instead. |
ProcessingExceptionHandler |
getMessageErrorHandler()
Returns the
MessageErrorHandler to use. |
MessageLogger |
getMessageLogger() |
ProduceExceptionHandler |
getProduceExceptionHandler()
Returns produceExceptionHandler.
|
AdaptrisMessageProducer |
getProducer()
Returns the
AdaptrisMessageProducer to use. |
java.lang.Boolean |
getSendEvents()
Return whether events should be sent.
|
ServiceCollection |
getServiceCollection()
Returns the
ServiceCollection to use. |
java.lang.String |
getUniqueId()
Returns any configured unique-id.
|
void |
handleBadMessage(AdaptrisMessage msg)
Handle a 'bad' message.
|
protected void |
handleBadMessage(java.lang.String logMsg,
java.lang.Exception e,
AdaptrisMessage msg) |
protected void |
handleChannelUnavailable(AdaptrisMessage msg)
Allows common functionality when the channel is unavailable.
|
void |
handleProduceException()
Handle an
Exception encountered producing a message. |
void |
init()
Because the order in which concrete workflows may need to init their components, this method simply ensures that the
MessageErrorHandler
is inited, and then delegates all other init requirements to the concrete implementation. |
protected abstract void |
initialiseWorkflow()
Initialise the workflow.
|
java.util.Date |
lastStartTime()
Get the last time this workflow was started
|
java.util.Date |
lastStopTime()
Get the last time this channel was stopped.
|
protected void |
logSuccess(AdaptrisMessage msg,
long start) |
MessageLogger |
messageLogger() |
Channel |
obtainChannel()
Returns a reference to this
Workflow 's Channel . |
java.lang.String |
obtainWorkflowId()
Returns what the workflow considers to be it's unique ID of the workflow.
|
void |
prepare()
Prepare for initialisation.
|
protected abstract void |
prepareWorkflow() |
protected void |
processingStart(AdaptrisMessage msg)
Mark the workflow having started processing a message.
|
void |
registerActiveMsgErrorHandler(ProcessingExceptionHandler meh)
Sets the
MessageErrorHandler to use for handling error messages. |
void |
registerChannel(Channel ch)
Sets a reference to this
Workflow 's Channel . |
void |
registerEventHandler(EventHandler eh)
Register the current event handler against this component.
|
void |
requestClose()
Request this component is closed.
|
void |
requestInit()
Request this component is init'd.
|
void |
requestStart()
Request this component is started.
|
void |
requestStop()
Request this component is stopped.
|
protected abstract void |
resubmitMessage(AdaptrisMessage msg)
Resubmit a message upon the channel becoming available again.
|
protected ProcessingExceptionHandler |
retrieveActiveMsgErrorHandler()
Accessor to allow sub-classes access to the
MessageErrorHandler that is in use. |
ComponentState |
retrieveComponentState()
Returns the last recorde
ComponentState . |
protected void |
sendMessageLifecycleEvent(AdaptrisMessage wip) |
void |
setChannelUnavailableWaitInterval(TimeInterval channelUnavailableWaitInterval)
|
void |
setComments(java.lang.String s) |
void |
setConsumer(AdaptrisMessageConsumer param)
Sets the
AdaptrisMessageConsumer to use. |
void |
setDisableDefaultMessageCount(java.lang.Boolean b)
Disable the default
MessageMetricsInterceptor that keeps a message count. |
void |
setInterceptors(java.util.List<WorkflowInterceptor> list) |
void |
setLogPayload(java.lang.Boolean b)
Deprecated.
since 3.8.4 use
setMessageLogger(MessageLogger) instead. |
void |
setMessageErrorHandler(ProcessingExceptionHandler errorHandler)
Sets a configured
MessageErrorHandler . |
void |
setMessageLogger(MessageLogger ml) |
void |
setProduceExceptionHandler(ProduceExceptionHandler p)
Sets produceExceptionHandler.
|
void |
setProducer(AdaptrisMessageProducer param)
Sets the
AdaptrisMessageProducer to use. |
void |
setSendEvents(java.lang.Boolean events)
Sets whether events should be sent.
|
void |
setServiceCollection(ServiceCollection services)
Sets the
ServiceCollection to use. |
void |
setUniqueId(java.lang.String id) |
void |
start()
Start this component.
|
protected abstract void |
startWorkflow()
Start the workflow.
|
void |
stop()
Stop this component.
|
protected abstract void |
stopWorkflow()
Stop the workflow.
|
protected void |
workflowEnd(AdaptrisMessage input,
AdaptrisMessage output)
Mark the workflow as finished on this message.
|
protected void |
workflowStart(AdaptrisMessage msg)
Mark the workflow having accepted a message.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onAdaptrisMessage
protected transient org.slf4j.Logger log
protected transient EventHandler eventHandler
protected transient java.util.Date startTime
protected transient java.util.Date stopTime
public WorkflowImp()
Creates a new instance with defaults to prevent NullPointerExceptions.
public void registerActiveMsgErrorHandler(ProcessingExceptionHandler meh)
Sets the MessageErrorHandler
to use for handling error messages. This may be configured at the Workflow, Channel
or Adapter level. May not be null.
registerActiveMsgErrorHandler
in interface Workflow
meh
- the MessageErrorHandler
to usepublic void registerEventHandler(EventHandler eh)
EventHandlerAware
registerEventHandler
in interface EventHandlerAware
eh
- the event handler currently in use.public final void prepare() throws CoreException
ComponentLifecycleExtension
prepare
in interface ComponentLifecycleExtension
CoreException
protected abstract void prepareWorkflow() throws CoreException
CoreException
public final void init() throws CoreException
Because the order in which concrete workflows may need to init their components, this method simply ensures that the
MessageErrorHandler
is inited, and then delegates all other init requirements to the concrete implementation.
init
in interface ComponentLifecycle
CoreException
- encapsulating any underlying ExceptionComponentLifecycle.init()
,
initialiseWorkflow()
protected abstract void initialiseWorkflow() throws CoreException
CoreException
- encapsulating any underlying Exceptionpublic final void start() throws CoreException
Because the order in which concrete workflows may need to start their components, this method simply ensures that the
MessageErrorHandler
is started, and then delegates to the concrete imp.
start
in interface ComponentLifecycle
CoreException
- encapsulating any underlying ExceptionComponentLifecycle.start()
,
startWorkflow()
protected abstract void startWorkflow() throws CoreException
CoreException
- encapsulating any underlying ExceptionComponentLifecycle.start()
public final void stop()
Because the order in which concrete workflows may need to stop their components, this method simply uses
stopWorkflow
to stop the concrete workflow, and then ensures that the MessageErrorHandler is closed.
stop
in interface ComponentLifecycle
ComponentLifecycle.stop()
,
stopWorkflow()
protected abstract void stopWorkflow()
public final void close()
Because the order in which concrete workflows may need to close their components, this method delegates all other close
requirements to the concrete implementation, after the concrete workflow has performed its close it ensures that the
MessageErrorHandler
is closed.
close
in interface ComponentLifecycle
ComponentLifecycle.close()
,
closeWorkflow()
protected abstract void closeWorkflow()
public void changeState(ComponentState s)
StateManagedComponent
Updates the state for the component ComponentState
.
changeState
in interface StateManagedComponent
public void requestInit() throws CoreException
StateManagedComponent
Request this component is init'd.
requestInit
in interface StateManagedComponent
CoreException
- wrapping any underlying Exceptionspublic void requestStart() throws CoreException
StateManagedComponent
Request this component is started.
requestStart
in interface StateManagedComponent
CoreException
- wrapping any underlying Exceptionspublic void requestStop()
StateManagedComponent
Request this component is stopped.
requestStop
in interface StateManagedComponent
public void requestClose()
StateManagedComponent
Request this component is closed.
requestClose
in interface StateManagedComponent
public ComponentState retrieveComponentState()
StateManagedComponent
Returns the last recorde ComponentState
.
retrieveComponentState
in interface StateManagedComponent
ComponentState
protected ProcessingExceptionHandler retrieveActiveMsgErrorHandler()
MessageErrorHandler
that is in use.protected void handleChannelUnavailable(AdaptrisMessage msg)
msg
- the current message.protected abstract void resubmitMessage(AdaptrisMessage msg)
msg
- the AdaptrisMessage.public void handleProduceException()
Workflow
Handle an Exception
encountered producing a message.
handleProduceException
in interface Workflow
Workflow.handleProduceException()
public void doProduce(AdaptrisMessage msg) throws ServiceException, ProduceException
This method contains the behaviour that varies between standard and request -reply workflows. It is overridden in
RequestReplyWorkflow
.
doProduce
in interface Workflow
msg
- the message to processProduceException
- if any occurServiceException
- not thrown by this implementationpublic void handleBadMessage(AdaptrisMessage msg)
Workflow
Handle a 'bad' message. A bad message is one which has caused an
Exception
in the ServceCollection
or
AdaptrisMessageProducer
.
handleBadMessage
in interface Workflow
msg
- the original version of the 'bad' messageWorkflow.handleBadMessage(AdaptrisMessage)
protected void sendMessageLifecycleEvent(AdaptrisMessage wip)
public java.lang.String obtainWorkflowId()
Workflow
Returns what the workflow considers to be it's unique ID of the workflow.
This may differ from any 'unique-id' element that has been set.
obtainWorkflowId
in interface Workflow
public java.lang.String friendlyName()
AdaptrisMessageListener
friendlyName
in interface AdaptrisMessageListener
public void setServiceCollection(ServiceCollection services)
Sets the ServiceCollection
to use. May not be null.
services
- the ServiceCollection
to usepublic ServiceCollection getServiceCollection()
Returns the ServiceCollection
to use.
ServiceCollection
to usepublic void setConsumer(AdaptrisMessageConsumer param)
Sets the AdaptrisMessageConsumer
to use. May not be null. Sets the unique ID of this Workflow based on the
consumer's destination's unique ID. If there is no destination (e.g. from a NullMessageConsumer
) , ID is set to
"default".
param
- the AdaptrisMessageConsumer
to usepublic AdaptrisMessageConsumer getConsumer()
Returns the AdaptrisMessageConsumer
to use.
getConsumer
in interface Workflow
AdaptrisMessageConsumer
to usepublic void setProducer(AdaptrisMessageProducer param)
Sets the AdaptrisMessageProducer
to use. May not be null.
param
- the AdaptrisMessagePRoducer
to usepublic AdaptrisMessageProducer getProducer()
Returns the AdaptrisMessageProducer
to use.
getProducer
in interface Workflow
AdaptrisMessageProducer
to usepublic void setMessageErrorHandler(ProcessingExceptionHandler errorHandler)
Sets a configured MessageErrorHandler
. Will over-ride any MEH configured at the Channel or Workflow level. May be
null.
errorHandler
- the configured MessageErrorHandler
public ProcessingExceptionHandler getMessageErrorHandler()
Returns the MessageErrorHandler
to use.
getMessageErrorHandler
in interface Workflow
MessageErrorHandler
to usepublic void setSendEvents(java.lang.Boolean events)
Sets whether events should be sent.
events
- whether events should be sent; default is null (true).public java.lang.Boolean getSendEvents()
Return whether events should be sent.
@Deprecated @Removal(version="3.11.0") public java.lang.Boolean getLogPayload()
setMessageLogger(MessageLogger)
instead.Returns true if payload should be logged.
@Deprecated @Removal(version="3.11.0") public void setLogPayload(java.lang.Boolean b)
setMessageLogger(MessageLogger)
instead.Sets whether payload should be logged.
b
- true if payload should be loggedpublic Channel obtainChannel()
Workflow
Returns a reference to this Workflow
's Channel
.
obtainChannel
in interface Workflow
Workflow
's Channel
Workflow.obtainChannel()
public void registerChannel(Channel ch) throws CoreException
Workflow
Sets a reference to this Workflow
's Channel
.
registerChannel
in interface Workflow
ch
- this Workflow
's Channel
CoreException
Workflow.registerChannel(com.adaptris.core.Channel)
public TimeInterval getChannelUnavailableWaitInterval()
public void setChannelUnavailableWaitInterval(TimeInterval channelUnavailableWaitInterval)
Sets the time the Workflow
implementation will wait if its parent Channel
is unavailable before resubmitting
the message.
channelUnavailableWaitInterval
- the timepublic long channelUnavailableWait()
public ProduceExceptionHandler getProduceExceptionHandler()
Returns produceExceptionHandler.
public void setProduceExceptionHandler(ProduceExceptionHandler p)
Sets produceExceptionHandler.
p
- the produceExceptionHandler to setpublic java.lang.String getUniqueId()
Workflow
Returns any configured unique-id.
getUniqueId
in interface AdaptrisComponent
getUniqueId
in interface Workflow
public void setUniqueId(java.lang.String id)
public java.util.List<WorkflowInterceptor> getInterceptors()
Workflow
getInterceptors
in interface Workflow
public void setInterceptors(java.util.List<WorkflowInterceptor> list)
public void addInterceptor(WorkflowInterceptor wi)
protected void workflowStart(AdaptrisMessage msg)
msg
- the input messageWorkflowInterceptor
protected void processingStart(AdaptrisMessage msg)
msg
- the input messageWorkflowInterceptor
protected void workflowEnd(AdaptrisMessage input, AdaptrisMessage output)
input
- the input messageoutput
- the message that was produced.WorkflowInterceptor
protected AdaptrisMessage copyExceptionHeaders(AdaptrisMessage workingCopy, AdaptrisMessage orig)
protected void handleBadMessage(java.lang.String logMsg, java.lang.Exception e, AdaptrisMessage msg)
protected void logSuccess(AdaptrisMessage msg, long start)
public java.util.Date lastStartTime()
lastStartTime
in interface Workflow
public java.util.Date lastStopTime()
lastStopTime
in interface Workflow
public java.lang.Boolean getDisableDefaultMessageCount()
public void setDisableDefaultMessageCount(java.lang.Boolean b)
MessageMetricsInterceptor
that keeps a message count.
If the workflow has a unique-id, and there are no MessageMetricsInterceptor
instances
configured on the workflow, one
is created with the same name as the workflow with a default configured
MetricsInterceptorImpl.setTimesliceDuration(com.adaptris.util.TimeInterval)
of 1
minute
b
- true to disable, default null (false);public boolean disableMessageCount()
Workflow
disableMessageCount
in interface Workflow
public MessageLogger getMessageLogger()
public void setMessageLogger(MessageLogger ml)
public void setComments(java.lang.String s)
setComments
in interface ConfigComment
public java.lang.String getComments()
getComments
in interface ConfigComment
public MessageLogger messageLogger()
protected AdaptrisMessage addConsumeLocation(AdaptrisMessage msg)