Skip to main content
Use this when the next step depends on the message: build passed or failed, a bug or a feature. A node publishes each message on a named output port, and an edge listens to one port with sourcePort. An edge with no sourcePort receives every port except error. A message on a port with no listening edge is dropped, so wire every port you care about.

Steps

1

Branch on a value

BRANCH in its default mode SELECT_KEY evaluates selector and looks the result up in cases; each case names an output port. defaultPort catches the rest. Save as router.json:
router.json
The ports are the distinct values of cases, plus defaultPort. A case that routes to a port with no outgoing edge fails validation.
2

Branch on a condition instead

With mode: EXPRESSION, each case key is a predicate and the first one that is true names the port:
The syntax is in the Expressions reference. With strictMode on (the default) a message that matches nothing and has no defaultPort fails the node; allowMultipleMatches emits on every matching case.
3

Route on how a command or request went

PROCESS_EXECUTOR with "failureMode": "CONTINUE", "routeByExitCode": true leaves on success or failure; HTTP_REQUEST does the same with "routeByStatus": true. Wire "sourcePort": "success" and "failure".
4

Filter, validate, fan out

  • FILTER passes messages that match condition and drops the rest.
  • VALIDATE sends messages that fail to its invalid port.
  • RECIPIENT_LIST sends one message to several recipients, each recipient a port, optionally in parallel.
  • To send the same message to several nodes without choosing, give the node several edges without sourcePort: every child receives every message.
5

Route failures and rejoin branches

With "onError": "ROUTE" in a node’s engine object, a message that fails all its attempts leaves on the error port: { "source": "classify", "target": "dead-letter", "sourcePort": "error" }. See Handle failures. Several branches may lead into one node; when it has several parents its engine.trigger join rule decides what a failed branch means.

Verify it worked

The RESULT event comes from node bugs. Start again with "kind":"idea" and it comes from other. To check the wiring before running, validate the workflow: the answer lists each node’s output ports (Validate and roll back).

Variations