Class WorkflowImp

    • Field Detail

      • log

        protected transient org.slf4j.Logger log
      • eventHandler

        protected transient EventHandler eventHandler
      • startTime

        protected transient java.util.Date startTime
      • stopTime

        protected transient java.util.Date stopTime
    • Constructor Detail

      • WorkflowImp

        public WorkflowImp()

        Creates a new instance with defaults to prevent NullPointerExceptions.

    • Method Detail

      • registerActiveMsgErrorHandler

        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.

        Specified by:
        registerActiveMsgErrorHandler in interface Workflow
        Parameters:
        meh - the MessageErrorHandler to use
      • initialiseWorkflow

        protected abstract void initialiseWorkflow()
                                            throws CoreException
        Initialise the workflow.
        Throws:
        CoreException - encapsulating any underlying Exception
      • stop

        public final void stop()
        Stop this component.

        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.

        Specified by:
        stop in interface ComponentLifecycle
        See Also:
        ComponentLifecycle.stop(), stopWorkflow()
      • stopWorkflow

        protected abstract void stopWorkflow()
        Stop the workflow.
      • close

        public final void close()
        Close this component.

        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.

        Specified by:
        close in interface ComponentLifecycle
        See Also:
        ComponentLifecycle.close(), closeWorkflow()
      • closeWorkflow

        protected abstract void closeWorkflow()
        Close the workflow.
      • retrieveActiveMsgErrorHandler

        protected ProcessingExceptionHandler retrieveActiveMsgErrorHandler()
        Accessor to allow sub-classes access to the MessageErrorHandler that is in use.
        Returns:
        the message error handler in use.
      • handleChannelUnavailable

        protected void handleChannelUnavailable​(AdaptrisMessage msg)
        Allows common functionality when the channel is unavailable.
        Parameters:
        msg - the current message.
      • resubmitMessage

        protected abstract void resubmitMessage​(AdaptrisMessage msg)
        Resubmit a message upon the channel becoming available again.
        Parameters:
        msg - the AdaptrisMessage.
      • sendMessageLifecycleEvent

        protected void sendMessageLifecycleEvent​(AdaptrisMessage wip)
      • obtainWorkflowId

        public java.lang.String obtainWorkflowId()
        Description copied from interface: 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.

        Specified by:
        obtainWorkflowId in interface Workflow
        Returns:
        the unique ID
      • setServiceCollection

        public void setServiceCollection​(ServiceCollection services)

        Sets the ServiceCollection to use. May not be null.

        Parameters:
        services - the ServiceCollection to use
      • getServiceCollection

        public ServiceCollection getServiceCollection()

        Returns the ServiceCollection to use.

        Returns:
        the ServiceCollection to use
      • setConsumer

        public 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".

        Parameters:
        param - the AdaptrisMessageConsumer to use
      • setProducer

        public void setProducer​(AdaptrisMessageProducer param)

        Sets the AdaptrisMessageProducer to use. May not be null.

        Parameters:
        param - the AdaptrisMessagePRoducer to use
      • setMessageErrorHandler

        public void setMessageErrorHandler​(ProcessingExceptionHandler errorHandler)

        Sets a configured MessageErrorHandler. Will over-ride any MEH configured at the Channel or Workflow level. May be null.

        Parameters:
        errorHandler - the configured MessageErrorHandler
      • setSendEvents

        public void setSendEvents​(java.lang.Boolean events)

        Sets whether events should be sent.

        Parameters:
        events - whether events should be sent; default is null (true).
      • getSendEvents

        public java.lang.Boolean getSendEvents()

        Return whether events should be sent.

        Returns:
        whether events should be sent
      • sendEvents

        public boolean sendEvents()
      • getChannelUnavailableWaitInterval

        public TimeInterval getChannelUnavailableWaitInterval()

        Get the time the Workflow implementation will wait if its parent Channel is unavailable before resubmitting the message.

        return the time it will wait.
      • setChannelUnavailableWaitInterval

        public void setChannelUnavailableWaitInterval​(TimeInterval channelUnavailableWaitInterval)

        Sets the time the Workflow implementation will wait if its parent Channel is unavailable before resubmitting the message.

        Parameters:
        channelUnavailableWaitInterval - the time
      • channelUnavailableWait

        public long channelUnavailableWait()
      • getProduceExceptionHandler

        public ProduceExceptionHandler getProduceExceptionHandler()

        Returns produceExceptionHandler.

        Returns:
        produceExceptionHandler
      • setProduceExceptionHandler

        public void setProduceExceptionHandler​(ProduceExceptionHandler p)

        Sets produceExceptionHandler.

        Parameters:
        p - the produceExceptionHandler to set
      • setUniqueId

        public void setUniqueId​(java.lang.String id)
      • getInterceptors

        public java.util.List<WorkflowInterceptor> getInterceptors()
        Description copied from interface: Workflow
        Return all the configured interceptors.
        Specified by:
        getInterceptors in interface Workflow
        Returns:
        all the configured interceptors.
      • workflowStart

        protected void workflowStart​(AdaptrisMessage msg)
        Mark the workflow having accepted a message.
        Parameters:
        msg - the input message
        See Also:
        WorkflowInterceptor
      • processingStart

        protected void processingStart​(AdaptrisMessage msg)
        Mark the workflow having started processing a message.
        Parameters:
        msg - the input message
        See Also:
        WorkflowInterceptor
      • workflowEnd

        protected void workflowEnd​(AdaptrisMessage input,
                                   AdaptrisMessage output)
        Mark the workflow as finished on this message.
        Parameters:
        input - the input message
        output - the message that was produced.
        See Also:
        WorkflowInterceptor
      • handleBadMessage

        protected void handleBadMessage​(java.lang.String logMsg,
                                        java.lang.Exception e,
                                        AdaptrisMessage msg)
      • logSuccess

        protected void logSuccess​(AdaptrisMessage msg,
                                  long start)
      • lastStartTime

        public java.util.Date lastStartTime()
        Get the last time this workflow was started
        Specified by:
        lastStartTime in interface Workflow
        Returns:
        workflow start time
      • lastStopTime

        public java.util.Date lastStopTime()
        Get the last time this channel was stopped. This is set when the channel is initialised so it may have been subsequently started.
        Specified by:
        lastStopTime in interface Workflow
        Returns:
        channel stop time
      • getDisableDefaultMessageCount

        public java.lang.Boolean getDisableDefaultMessageCount()
      • disableMessageCount

        public boolean disableMessageCount()
        Description copied from interface: Workflow
        Whether or not message-counts should be disabled on this workflow.
        Specified by:
        disableMessageCount in interface Workflow
      • setMessageLogger

        public void setMessageLogger​(MessageLogger ml)