# Routing Nodes

# Processor

Processor nodes brings easy to use loops and OOP (object oriented programming) features to the flow programming paradigm. Three nodes allow you to create extensible, scoped, looped, and prioritized flows. You can organize flows for readability and create extendable design patterns.

Processor provides following key features:

  • Late binding - extend complex flows without modifying the original flow
  • Looping - call flow segments repeatedly with conditional iteration
  • Prioritize flows - allow for execution of subflows based on priority number.

The processor node works like a subflow, allowing you to define a reusable flow segment between the node's processor in and processor out.

Processor node invokes the processor in node by a prefix naming schema; allowing for multiple add-on flow segments to be appended to the original flow. Processor node's name determines the name of the corresponding processor in node that will be activated. Use the processor node's name as a prefix for all subsequent processor in nodes that you wish to be callable by the processor node. For instance, an processor node named "Sample", will call any processor in nodes with names like "Sample in", "Sample-in", "Sample_Exercise", or "sample.acme.com".

Subflow Context

Subflow context is the context defined when the flow is having a processor node with subflow operation selected. This context starts from the processor in node to processor out node. The variables defined in the sub flow will be visible across all the nodes in the sub flow but will not be visible on the main flow context or on any other subflow context. Environment variables and message object will be visible across all the nodes placed on a subflow.

Example:

How to use a Processor node

# Split

Split node splits the message into a single message into a sequence of messages. The exact behavior of the node depends on the type of msg.payload.

If the message type is String\Buffer then the message is split using the specified character (default: \n), buffer sequence or into fixed lengths.

If the message type is an Array then the message is split into either individual array elements, or arrays of a fixed-length.

If the message type is an Object then the message is split and sent for each key/value pair of the object.

Example:

How to use a Split node

How to use Split node using the String\Buffer option

How to use Split node using fixed length option

How to use Split node using Object key value pair

# Join

Join node turns a sequence of messages into a single message. The node provides three modes of operation.

Automatic

This mode attempts to reverse the action of a previous split node.

Manual

This mode allows finer control on how the incoming message sequence should be joined.

Reduce

This mode allows a JSONata expression to be run against each message in the sequence and the result accumulated to produce a single message.

Example:

How to use join node in manual mode option

How to use join node in reduced sequence mode option

# Switch

The Switch node allows messages to be routed to different branches of a flow by evaluating a set of rules against each message.

The node will route the message to the first matching rule.

# Fields

  • Property: Rules are evaluated against the value of this field. It supports dynamic expressions.

  • Rules: Dynamic list of rules to compare against the property.

# Rule Conditions

  • equals: true iff property === value
  • not equals: true iff property !== value
  • less than: true iff property < value
  • at most: true iff property <= value
  • greater than: true iff property > value
  • at least: true iff property >= value
  • is between: true iff property >= value1 && property <= value2
  • contains: true iff _property contains substring value
  • regex: true iff _property matches the regular expression value
  • is true: true iff property is TRUE
  • is false: true iff property is FALSE
  • is nil: true iff property is null or undefined
  • is not nil: true iff property is not null nor undefined
  • is of type: true iff property is of the type value
  • is empty: true iff strings, arrays or buffers are of length 0, or if object is not null and it does not have any keys.
  • is not empty: true iff strings, arrays or buffers are of length more than 0, or if object is not null and it has at least one key.
  • otherwise: true if rest of rules were evaluated to false.

WARNING

The otherwise rule is optional, but if present ensure that it is placed at the end of the list of rules.

# Examples

How to use a Switch node.

# Scatter

# Gather