Header enricher version 2

Header Enricher Version 2

The header enricher can add, update or remove headers on a message.

In the table below, you will find an explanation of these properties. All attributes with a ‘*’ are mandatory.

Attribute Description
Name* By default, we fill this out with the technical ‘tag’, followed by a serial number. Changing the name is optional.
Enabled Check this box if you want this service to be enabled.
Header-operation

Here you can change or create properties.

By pushing   , you can create one or more extra header property lines. The header properties are explained in the table below. You can also remove a header property by pressing the  button next to the header property you want to remove.

Description

Description of the specific service. This is for documentation purposes.

Header operations

It is important to understand that a ConnectMessage has headers on two levels:

  • ConnectMessage level
    Headers that are set on the ConnectMessage itself.
  • ConnectMessagePart level
    Headers that are set on a specific ConnectMessagePart.

The header enricher allows you to add, update or remove headers on both levels. If you want to operate on part level, you need to specify the part name.

New header values can be static values, copied from other headers or the result of a header operation. Supported operations are:

  • Fixed value
    A fixed value that is set on the header.
  • Copy from header
    The value of another header is copied to the header.
  • JSONPath
    The first match of a JSONPath expression is set on the header.
  • XPath
    The first match of an XPath expression is set on the header.
  • Regex
    The first match of the first capturing group of a regular expression is set on the header.
  • UUID
    A new UUID is generated and set on the header.
  • Date-time
    A date-time timestamp is generated and set on the header.
  • Epoch timestamp
    An epoch timestamp is generated and set on the header. The epoch timestamp is the number of (milli)seconds since 1970-01-01T00:00:00Z.
  • Script
    A JavaScript script is evaluated and the result is set on the header.

In a single header enricher, several such operations can be defined. The order of the operations is important, as the result of one operation can be used as input for the next operation. For example, you can first set a header to a fixed value, and then append the value of another header to it.

Date-time timestamp

A date-time timestamp is a local date-time timestamp, with an optional offset, formatted according to a chosen predefined format or a custom user-defined format. The following predefined formats are supported:

  • ISO_LOCAL_DATE_TIME
    The ISO local date-time format, such as '2011-12-03T10:15:30'.
  • ISO_LOCAL_DATE
    The ISO local date format, such as '2011-12-03'.
  • ISO_LOCAL_TIME
    The ISO local time format, such as '10:15:30'.

The user-defined format is a string formatted according to the DateTimeFormatter class of Java 8. For example, 'yyyy-MM-dd HH:mm:ss.SSS' will result in a date-time timestamp such as '2011-12-03 10:15:30.123'. Please see the Java 8 documentation for more information.

Substitution syntax

The fixed, JSONPath, XPath and regex expression can when the *Enable Substitution Syntax* option is enabled contain substitution syntax. This syntax allows you to use the value of headers and message part payloads in the expression. For example, in the following JSONPath expression:

$.a.jsonpath.expression.:header[a-connect-message-header]


the sub-expression :header[a-connect-message-header] will be substituted with the value of the ConnectMessage header a-connect-message-header.

The syntax the following expressions:

  • :header[header-name]
    The value of the ConnectMessage header with the given name is used.
  • :part[part-name]
    The value of the ConnectMessagePart payload with the given name is used. Only payloads of type TEXT are supported.
  • :partHeader[part-name,header-name]
    The value of the ConnectMessagePart header with the given name in the part with the given name is used.

The substituted value itself can also contain substitution syntax. For example, if the value of the ConnectMessage header a-connect-message-header is :part[a-connect-message-part] the JSONPath expression.

$.a.jsonpath.expression.:header[a-connect-message-header]

will be effectively evaluated as

$.a.jsonpath.expression.:part[a-connect-message-part]

To avoid infinite recursion, the substitution syntax is only supports a finite number of levels.

JavaScript support

The JavaScript script last statement must be an expression that evaluates to the new header value. For example:

var x = 42;
x;


will result in the header value `42`.

When using JavaScript, the following variables are available:

  • message or connectmsg
    The ConnectMessage.
  • headers or properties
    The ConnectMessage headers.
  • messageParts
    The ConnectMessage parts.
  • log
    A logger that can be used to log messages.

For example:

var x = 42;
log.info("The answer is " + x);
x + headers.get("a-connectmessage-header");

will result in the header value 42 with the value of the ConnectMessage header a-connectmessage-header appended. This script will also log the message The answer is 42.

Header operation - attributes

Attribute Description
Header Operation

Should the header be added, updated or deleted?
This attribute can have the following values:

  • ADD_OR_UPDATE_HEADER
    Add or update a ConnectMessage(Part) header.
  • DELETE_HEADER
    Delete a ConnectMessage(Part) header.
Target Header Message Part Name

NOTE: This attribute is only visible when the attribute Target Header Location has value CONNECT_MESSAGE_PART_HEADER.

The name of the ConnectMessagePart of the target header.

Target Header Name

NOTE: This attribute is required, and must have a value.

The name of the header to add, update or delete.

Update Strategy

NOTE: This attribute is only visible when the attribute Header Operation has value ADD_OR_UPDATE_HEADER.

The update strategy to use if the header already exists.
This attribute can have the following values:

  • OVERWRITE
    Overwrite the header if it already exists.
  • DO_NOT_OVERWRITE
    Do not overwrite the header if it already exists.
  • APPEND
    Append the value to the header if it already exists.
  • PREPEND
    Prepend the value to the header if it already exists.
Value Specification Type

NOTE: This attribute is only visible when the attribute Header Operation has value ADD_OR_UPDATE_HEADER.

The type of value specification to use.
This attribute can have the following values:

  • FIXED_VALUE
    The header value is a fixed value.
  • XPATH
    The header value is the result of an XPath expression.
  • JSONPATH
    The header value is the result of a JSONPath expression.
  • REGEX
    The header value is the result of a regular expression.
  • SCRIPT
    The header value is the result of a script.
  • DATE_TIME
    The header value is the current date-time with an optional offset and in a certain date-time format.
  • EPOCH_TIMESTAMP
    The header value is the current epoch timestamp in either seconds or milliseconds.
  • UUID
    The header value is a random UUID.
  • COPY_FROM_HEADER
    The header value is the value of another header.
Date Time Offset

NOTE: This attribute is only visible when the attribute *Value Specification Type* has value *DATE_TIME*.

The positive or negative offset in time units to add to the current date time value.

Date Time Offset Unit

NOTE: This attribute is only visible when the attribute Value Specification Type has value DATE_TIME.

The unit of the offset.
This attribute can have the following values:

  • NANOS
  • MILLIS
  • MICROS
  • SECONDS
  • MINUTES
  • HOURS
  • DAYS
  • WEEKS
  • MONTHS
  • YEARS
Date Time Format

NOTE: This attribute is only visible when the attribute Value Specification Type has value DATE_TIME.

The date time format to use. When using a custom format, use the custom-date-time-format attribute to specify the desired format. This attribute can have the following values:

  • ISO_LOCAL_DATE_TIME
    ISO 8601 date time format (yyyy-MM-dd HH:mm:ss), e.g. 2007-12-03 10:15:30
  • ISO_LOCAL_DATE
    ISO 8601 date format (yyyy-MM-dd), e.g. 2007-12-03
  • ISO_LOCAL_TIME
    ISO 8601 time format (HH:mm:ss), e.g. 10:15:30
  • CUSTOM_DATE_TIME_FORMAT
    Custom date time format. See the documentation for more information and examples of formats.
Custom Date Time Format

NOTE: This attribute is only visible when the attribute Date Time Format has value CUSTOM_DATE_TIME_FORMAT.

The custom date time format to use. See the documentation for more information and examples of formats.

Epoch Timestamp Type

NOTE: This attribute is only visible when the attribute Value Specification Type has value EPOCH_TIMESTAMP.

The type of epoch timestamp to use.
This attribute can have the following values:

  • OF_SECONDS
    The number of seconds since 1970-01-01T00:00:00Z.
  • OF_MILLISECONDS
    The number of milliseconds since 1970-01-01T00:00:00Z.
Fixed Value

NOTE: This attribute is only visible when the attribute Value Specification Type has value FIXED_VALUE.

Fixed value to set the header to.

XPath Expression

NOTE: This attribute is only visible when the attribute Value Specification Type has value XPATH.

The XPath expression to perform.

JSONPath Expression

NOTE: This attribute is only visible when the attribute Value Specification Type has valuee JSONPATH.

The JSONPath expression to perform.

Regex Expression

NOTE: This attribute is only visible when the attribute Value Specification Type has value REGEX.

The regex expression to perform. Note that if the regex contains one or more capturing groups, the first capturing group match will be used as the resulting header value. Otherwise the entire match will be used as the header value.

Input Message Part Name

NOTE: This attribute is only visible when the attribute Value Specification Type has value JSONPATH, XPATH, or REGEX.

The name of the ConnectMessagePart to use as input for the JSONPath, XPath or regex expression.

Enable Substitution Syntax

NOTE: This attribute is only visible when the attribute Value Specification Type has value Fixed, JSONPATH, XPATH, or REGEX.

Enable the :header[...], :part[...] and :partHeader[...] notation in the JSONPath, XPath or regex expression.

Reference to script

NOTE: This attribute is only visible when the attribute Value Specification Type has value SCRIPT.

A reference to a script that produces the header value.

Header To Copy From Location

NOTE: This attribute is only visible when the attribute Value Specification Type has value COPY_FROM_HEADER.

Should the header be copied from a ConnectMessage header or from a ConnectMessagePart header?
This attribute can have the following values:

  • CONNECT_MESSAGE_HEADER
    The header to copy the value from is a ConnectMessage header.
  • CONNECT_MESSAGE_PART_HEADER
    The header to copy the value from is a ConnectMessagePart header.
Header To Copy From Message Part Name

NOTE: This attribute is only visible when the attribute Header To Copy From Location has value CONNECT_MESSAGE_PART_HEADER.

The name of the ConnectMessagePart of the header to copy the value from.

Header To Copy From

NOTE: This attribute is only visible when the attribute Value Specification Type has value COPY_FROM_HEADER.

The name of the header to copy the value from.