Event Handlers
Eventing in Conductor provides for loose coupling between workflows and support for producing and consuming events from external systems.
This includes:
- Being able to produce an event (message) in an external system like SQS or internal to Conductor.
- Start a workflow when a specific event occurs that matches the provided criteria.
Conductor provides SUB_WORKFLOW task that can be used to embed a workflow inside parent workflow. Eventing supports provides similar capability without explicitly adding dependencies and provides fire-and-forget style integrations.
Event Task
Event task provides ability to publish an event (message) to either Conductor or an external eventing system like SQS. Event tasks are useful for creating event based dependencies for workflows and tasks.
See Event Task for documentation.
Event Handler
Event handlers are listeners registered that executes an action when a matching event occurs. The supported actions are:
- Start a Workflow
- Fail a Task
- Complete a Task
Event Handlers can be configured to listen to Conductor Events or an external event like SQS.
Configuration
Event Handlers are configured via /event/
APIs.
Structure
{
"name" : "descriptive unique name",
"event": "event_type:event_location",
"condition": "boolean condition",
"actions": ["see examples below"]
}
condition
is an expression that MUST evaluate to a boolean value. A Javascript like syntax is supported that can be used to evaluate condition based on the payload.
Actions are executed only when the condition evaluates to true
.
Examples
Condition
Given the following payload in the message:
The following expressions can be used in condition
with the indicated results:
Expression | Result |
---|---|
$.version > 1 |
true |
$.version > 10 |
false |
$.metadata.length == 300 |
true |
Actions
Examples of actions that can be configured in the actions
array:
To start a workflow
{
"action": "start_workflow",
"start_workflow": {
"name": "WORKFLOW_NAME",
"version": "<optional_param>",
"input": {
"param1": "${param1}"
}
}
}
To complete a task
{
"action": "complete_task",
"complete_task": {
"workflowId": "${workflowId}",
"taskRefName": "task_1",
"output": {
"response": "${result}"
}
},
"expandInlineJSON": true
}
To fail a task*
{
"action": "fail_task",
"fail_task": {
"workflowId": "${workflowId}",
"taskRefName": "task_1",
"output": {
"response": "${result}"
}
},
"expandInlineJSON": true
}
Expanding stringified JSON elements in payload
expandInlineJSON
property, when set to true will expand the inlined stringified JSON elements in the payload to JSON documents and replace the string value with JSON document.
This feature allows such elements to be used with JSON path expressions.