public class Loop extends AbstractDispatchLayer<com.fasterxml.jackson.databind.JsonNode>
The layer is configured with a LoopConfiguration
, where an activity
has been set as the
condition
.
After a job has been successful further down the dispatch stack, the loop
layer will invoke the conditional activity to determine if the job will be
invoked again. If LoopConfiguration.isRunFirst()
is false, this test
will be performed even before the first invocation. (The default
runFirst=true is equivalent to a do..while construct, while runFirst=false is
equivalent to a while.. construct.)
A job will be resent down the dispatch stack only if the conditional activity returns a reference to a string equal to "true" on its output port "loop".
If a job or the conditional activity fails, the while-loop is interrupted and the error is sent further up.
Note that the LoopLayer will be invoked for each item in an iteration, if you want to do the loop for the whole collection (ie. re-iterating if the loop-condition fails after processing the full list) - create a nested workflow with the desired depths on it's input ports and insert this LoopLayer in the stack of the nested workflow's processor in parent workflow.
It is recommended that the LoopLayer is to be inserted after the
ErrorBounce
layer, as this layer is needed for registering errors
produced by the LoopLayer. If the user requires retries
and
failovers
before checking the while condition, such layers
should be below LoopLayer.
Modifier and Type | Class and Description |
---|---|
class |
Loop.ConditionCallBack |
Modifier and Type | Field and Description |
---|---|
protected Map<String,AbstractDispatchEvent> |
incomingJobs |
static String |
LOOP_PORT |
protected Map<String,AbstractDispatchEvent> |
outgoingJobs |
static String |
URI |
CLEANUP_DELAY_MS, cleanupTimer, dispatchStack
Constructor and Description |
---|
Loop() |
Modifier and Type | Method and Description |
---|---|
void |
configure(com.fasterxml.jackson.databind.JsonNode config)
When the item is built from the workflow definition XML the object is
first constructed with a default constructor then this method is called,
passing in the configuration bean returned by getConfiguration().
|
void |
finishedWith(String owningProcess)
Called when there will be no more events with the specified process
identifier, can be used to purge cached state from layers within the
stack
|
com.fasterxml.jackson.databind.JsonNode |
getConfiguration()
Each item stores configuration within a bean of type ConfigurationType,
this method returns the configuration.
|
Processor |
getProcessor() |
void |
receiveJob(DispatchJobEvent jobEvent)
Receive a single job and associated set of activities from the layer
above
|
void |
receiveJobQueue(DispatchJobQueueEvent jobQueueEvent)
Receive a pointer to the job queue along with a set of activities, this
is received from the layer above in the dispatch stack or from the
DispatchStackImpl object itself if this is the top layer.
|
void |
receiveResult(DispatchResultEvent resultEvent)
Receive a result from the layer below
|
void |
receiveResultCompletion(DispatchCompletionEvent completionEvent)
Receive a (possibly partial) completion event from the layer below.
|
getAbove, getBelow, receiveError, setDispatchStack
public static final String URI
protected Map<String,AbstractDispatchEvent> incomingJobs
protected Map<String,AbstractDispatchEvent> outgoingJobs
public static final String LOOP_PORT
public void configure(com.fasterxml.jackson.databind.JsonNode config)
Configurable
public void finishedWith(String owningProcess)
DispatchLayer
finishedWith
in interface DispatchLayer<com.fasterxml.jackson.databind.JsonNode>
finishedWith
in class AbstractDispatchLayer<com.fasterxml.jackson.databind.JsonNode>
public com.fasterxml.jackson.databind.JsonNode getConfiguration()
Configurable
public void receiveJob(DispatchJobEvent jobEvent)
DispatchLayer
receiveJob
in interface DispatchLayer<com.fasterxml.jackson.databind.JsonNode>
receiveJob
in class AbstractDispatchLayer<com.fasterxml.jackson.databind.JsonNode>
public void receiveJobQueue(DispatchJobQueueEvent jobQueueEvent)
DispatchLayer
receiveJobQueue
in interface DispatchLayer<com.fasterxml.jackson.databind.JsonNode>
receiveJobQueue
in class AbstractDispatchLayer<com.fasterxml.jackson.databind.JsonNode>
public void receiveResult(DispatchResultEvent resultEvent)
DispatchLayer
receiveResult
in interface DispatchLayer<com.fasterxml.jackson.databind.JsonNode>
receiveResult
in class AbstractDispatchLayer<com.fasterxml.jackson.databind.JsonNode>
public void receiveResultCompletion(DispatchCompletionEvent completionEvent)
DispatchLayer
receiveResultCompletion
in interface DispatchLayer<com.fasterxml.jackson.databind.JsonNode>
receiveResultCompletion
in class AbstractDispatchLayer<com.fasterxml.jackson.databind.JsonNode>
public Processor getProcessor()
getProcessor
in class AbstractDispatchLayer<com.fasterxml.jackson.databind.JsonNode>
Copyright © 2015–2016 The Apache Software Foundation. All rights reserved.