Shared activity behaviour.
- Activity lifecycle
new Activity(Behaviour, activityDefinition, context)activate()deactivate()discard()getApi(message)getActivityById(id)getState()init([initContent])addInboundListeners()removeInboundListeners()shake()next()on(eventName, handler[, eventOptions])once(eventName, handler[, eventOptions])recover(state)resume()run([runContent])stop()waitFor(eventName[, onMessage])evaluateOutbound(brokerMessage, discardRestAtTake, callback)
All activities except EventBasedGateway share this lifecycle. The EventBasedGateway takes care of it's own outbound in the Behaviour.
Arguments:
Behaviour: activity Behaviour function, called with newactivityDefinition: activity definition object from serializable contextcontext: shared context
Activity properties:
id: activity idtype: activity typename: activity nameattachedTo: if this is a BoundaryEvent, the activity instance it is attached to; otherwisenullBehaviour: passed activity Behaviour function, invoked with newbehaviour: activity behaviour from serializable contextbpmnIo: BpmnIO extension if presentbroker: activity brokercounters: counters for completed runs etcenvironment: shared environmenteventDefinitions: list of event definition instancesexecution: getter for current execution instanceexecutionId: current unique execution idextensions: object with extensionsformatter: per-activity formatter that resolves pending format messagesinbound: list of inbound sequence flowsinitialized: boolean indicating that the activity has been initialized (initcalled)isCatching: boolean indicating that the activity is a catching eventisConvergingGateway: boolean indicating that the activity is a parallel or inclusive gateway with more than one incoming sequence flow, converging by monitoring its upstream peersisEnd: boolean indicating that the activity has no outbound sequence flowsisForCompensation: boolean indicating that the activity is for compensationisMultiInstance: boolean indicating that the activity has loop characteristicsisParallelGateway: boolean indicating if the activity is a parallel gatewayisParallelJoin: deprecated, useisConvergingGatewaycombined withisParallelGateway. Boolean indicating if the activity is a parallel gateway with inbound flows from more than one source activityisRunning: boolean indicating if the activity is runningisStart: boolean indicating if the activity a start activityisSubProcess: boolean indicating if the activity is a sub processisThrowing: boolean indicating that the activity is a throwing eventisTransaction: boolean indicating that the activity is a transactionlogger: activity logger instanceoutbound: list of outbound sequence flowsparent: activity parentid: id of parenttype: parent type
parentElement: activity parent process or sub process referencelane: activity lane reference if anystatus: current run statusentered: Run entered, triggered by taken inbound flowstarted: Run startedexecuting: Executing activity behaviourexecuted: Activity behaviour execution completed successfullyend: Run end, take outbound flowsdiscard: Entering discard run, triggered by discarded inbound flowdiscarded: Run was discarded, discard outbound flowserror: Activity behaviour execution failed, discard runformatting: Formatting next run message
stopped: boolean indicating if the activity is in a stopped statetriggeredByEvent: boolean indicating that the activity (sub process) is triggered by an event
Start listening on inbound sequence flow(s) events.
Stop listening for inbound sequence flow(s) events.
Discard activity. If the activity is running - discard run.
Get activity api.
Arguments:
message: activity broker message
Returns activity api
Get activity by id from context.
Get activity state. If environment.settings.disableTrackState === true the state may be undefined if the task is not running.
Initialize the activity without running. Publishes an activity.init event with an execution id reserved for the next run, and queues a non-persistent activity.init message on the activity's inbound queue. When the inbound queue is consumed the activity runs with that reserved id. This is how start activities and link catch events are armed.
Arguments:
initContent: optional object merged into the init message contentproperties: optional message properties merged into the queued inbound message
Subscribe to inbound sequence flow events. Called internally from activate() and rarely needs to be called directly.
Unsubscribe from inbound sequence flow events. Counterpart to addInboundListeners().
Walk outbound sequence flows for shake analysis. Used to discover reachable flows from this activity.
Take next message in run-queue. Only appears if environment settings have step: true.
Listen for events.
Arguments:
eventName: name of eventhandler: required function called when events occurapi: activity api
eventOptions: passed to underlying broker as consume options
Listen for event.
Arguments:
eventName: name of eventhandler: required function called when event occurapi: activity api
eventOptions: passed to underlying broker as consume options
Recover activity from state.
Resume recovered or stopped activity.
Run activity.
Arguments:
runContent: optional object containing extra content for the broker run messages.
Stop activity run.
Wait for event to occur as promised.
Arguments:
eventName: name of eventonMessage: optional message callback for event filtering purposes. Return false if the promise should not resolve. Called with the following arguments:routingKey: broker message routing keymessage: actual message that match event nameowner: message owner, in this case probably the actual activity instance
Returns Promise that will resolve with activity api on event name or reject on error.
Evaluate all outbound sequence flows.
Arguments:
brokerMessage: broker message that will be passed to conditiondiscardRestAtTake: boolean, discard all other outbound flows if one flow is takencallback: function with signature,(err, outbound)err: occasional erroroutbound: list with flow actions, i.e. discard or takeid: outbound flow idaction: discard or take as stringisDefault: boolean indicating if flow is default flowresult: result of conditionmessage: optional message passed from argumentbrokerMessage.content.message
