Klevr Product Documentation logo

Routing Loop Stage

The Routing Loop stage allows for the termination of loops within Integration Hub integrations, to prevent infinite loops.

Stage Overview

The Routing Loop stage allows for the termination of loops within Integration Hub integrations, to prevent infinite loops.

This may be required where an integration flow includes a circular flow of stages (e.g. using a Routing Source stage that emits an event which returns to an earlier stage in the integration).

Stage Definition File Location

All Routing Loop stages are defined by creating an appropriately formatted JSON definition file in the following location:

interfaces
{businessUnitCode}
{domainCode}
{integrationName}
rt
loop
{STAGE_NAME}.json

Stage JSON Definition File Format

The JSON definition file for a Routing Loop stage is as follows:

{
  "name": "stage-name",
  "displayName": "Brief Stage Title",
  "description": "Brief description of the stage.",
  "enabled": "$env:STATUS_<INTEGRATION_NAME>",
  "source": "source-event",
  "concurrency": 10,
  "maximumLoops": <integer-of-max-loops>,
  "emitError": false,
  "emitErrorTerminateSuccess": false,
  "preLogTransformSchemaFileName": "schemas/path/to/schema/schema-name.liquid",
  "preLogTransformSchemaType": "liquid|javascript",
  "preLogTransformFormat": "json|xml|csv"
}
PropertyDescription
nameThe name of the stage.
displayNameOptional (but highly recommended). A short (3 or 4 word) "display name" for the stage, used as a "title" of the stage in the Integration Hub Portal service's self-documentation capability.
descriptionOptional (but highly recommended). A brief (10 to 15 word) description of the stage, used as a brief description of the stage's purpose in the Integration Hub Portal service's self-documentation capability. For a more detailed explanation (when needed), use the stage markdown feature.
enabledOptional boolean flag (true or false). Default is true.

Generally set via a DevOps variable. Controls if the stage is deployed enabled or not.
sourceThe source event that the stage subscribes to. See Pub/Sub Model.

Alternatively, sources may be supplied, and an array of one or more source events can be subscribed to.
concurrencyOptional number of concurrent runs permitted for the stage. Default is 10.
maximumLoopsThis integer value will be the maximum number of times that this stage can execute in a single integration. If the stage tries to execute more times than the allowed maximum loops, then the stage will terminate with an error condition.
emitErrorOptional boolean flag (true or false). Default is false. When true, the stage will emit a payload if the maximum permitted number of loops is detected, rather than terminating with an error condition. See below for more info.
emitErrorTerminateSuccessOptional boolean flag (true or false). Default is false. When true, and when emitError is also true, the stage will terminate with a Successful state, rather than a Failed state, in the event of an error being detected and emitted.

When the stage is configured to operate in this way, the integration should be defined so that a subsequent stage, or series of stages, will be triggered by the emitted error payload to "handle" the error condition in such a way that reporting and alerting on the error (as would happen if the stage terminated with a Failed state) is unnecessary.

Pre-Logging Transformation

This stage supports the optional pre-logging transformation feature using the following fields:

  • preLogTransformSchemaFileName
  • preLogTransformSchemaType
  • preLogTransformFormat

See the Pre-Logging Transformation for details.

Output Format

The stage will output the payload from the previous stage.

Emit Error Payload

In the event that the emitError option has been set to true and the maximum permitted number of loops is reached, then the stage will emit a payload in the following format:

{
    "error": "Routing stage has reached the limit of X attempts"
}

where "X" is the maximumLoops value.

The event used to emit the payload will be the full stage name with -error appended, e.g. rt-loop-stage-name-error.

Last updated on