string appender

String Appender

Version: 17.07

Supported Since: 17.01

What is a String Appender?

A String Appender is a processing element which can be used to append/prepend strings and store the resulting string as a scope variable. This element has two modes the normal node and the advanced mode. In the normal mode what it allows is to extract a value such a transport header, a message property or a scope variable from the message context, then append a given string into it and finally store the resulting string as a scope variable.

In this advanced a string append template can be given with a set of expressions or placeholders which relate data in the message context and the template will be used to compose the final string replacing the placeholders with relevant values from message context at runtime. One advantage of the advanced mode is that it supports appending/pre-pending multiple elements unlike the normal mode which only supports just two elements. Another advantage of the advanced mode is that it supports more data to be extracted from message context to compose the string along with the set supported in normal mode. More details about the advanced mode can be found under description of the string append template in the Parameters section.

In order to use this processing element, you must first select the String Processors dependency from the processor list when you are creating an empty Ultra project. If you have already created a project, you can add this dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Processors list, select the String Processors dependency.

Alternatively, you can add the following dependency to the maven pom.xml manually.

<dependency>
    <groupId>org.adroitlogic.x.processors</groupId>
    <artifactId>x-processor-string</artifactId>
    <version>17.07</version>
</dependency>
string appender outports

Out Ports

Next

The message will be sent to this outport if the string appending operation is successful

On Exception

The message will be sent to this outport if the processing element failed in string appending operation

Parameters

Variable Name*

Basic

Name for the scope variable to store the resulting string after append/prepend operation.

Advanced Mode*

Basic

Boolean parameter which can used to switch to advanced mode. Default value is false therefore by default processing element is in simple mode. In advanced mode an append template can be used to compose the new string. Read the description on append template parameter for more details on that.

Extraction Type*

Basic

Defines how the value which is to be subjected to append/prepend operation, is extracted from message context. This is an select type parameter and has following options to be selected from.

  • HEADER - The value of a message transport header should be extracted

  • PROPERTY - The value of a message property should be extracted

  • VARIABLE - The value of a scope variable in any scope should be extracted

  • CURRENT_SCOPE_VARIABLE - The value of a scope variable which is in current scope should be extracted

Note that this parameter is not used in Advanced Mode.

Extraction Name

Basic

Depending on the selected Extraction Type, input for this parameter should vary as follows.

  • HEADER - In this case the value of this parameter should be the name of the transport header

  • PROPERTY - In this case the value of this parameter should be the name of the message property

  • VARIABLE - In this case the value of this parameter should be the name of the scope variable

  • CURRENT_SCOPE_VARIABLE - In this case the value of this parameter should be the name of the scope variable in current context.

Note that this parameter is not used in Advanced Mode.

Should Prepend*

Basic

Boolean parameter which determines whether to do an append operation or prepend operation. If this is set to true the operation will be prepend instead of append. Default value is false and hence the default operation is append.

Note that this parameter is not used in Advanced Mode.

Appending/Pre-pending String*

Basic

String to be appended/prepended.

Note that this parameter is not used in Advanced Mode.

String Append Template*

Basic

This parameter accepts a string append template which can be a plain text string can be a plain text string or any combination of expressions in following format.

  • @{message.headers.<header_name>} - To compose a string with a message header. <header_name> must be replaced with a transport header name. i.e @{message.headers.Content-Type}

  • @{message.headers} - To compose a string with all message headers.

  • @{message.properties.<property_name>} - To compose a string with a message property. <property_name> must be replaced with a property name.

  • @{message.properties} - To compose string with all message properties.

  • @{message.payload} - To compose string with current payload

  • @{variable.<variable_name>} - To compose string with a scope variable. <variable_name> must be replaced with a variable name. i.e @{variable.myvar}

  • @{message.id} - To compose a string with message id

  • @{mc.id} - To compose a string with message context id

A sample string append template is shown below.

  • Payload: @{message.payload} ContentType: @{message.headers.Content-Type} MessageID: @{message.id} - a string append template which composes a string with message payload, content-type transport header and message id

Further following place holder can be used to get the current timestamp.

  • @{current.timestamp} - this will use the default timestamp pattern yyMMddHHmmssZ

  • @{current.timestamp.<timestamp_pattern>} - this will use the given timestamp pattern. Note that timestamp pattern given here should be a pattern compatible with SimpleDateFormat.

Message property names and variable names are case sensitive like all Java Variables). Therefore exact case of message property name or variable name must be used for the string append template in the form @{message.properties.<name>} or @{variable.<name>}.

When @{message.headers.<name>}, @{message.properties.<name>}, @{message.payload} or @{variable.<name>} is used in string append template and if the requested values are not found "null" will be used for those placeholders when composing the string.

Sample Use Case

In integration flows sometimes there can be a requirement to send custom headers out with a request. One example would be to send a the flow name with the message id as a header. This sample use case will be used to demonstrate the String Appender processing element. The sample flow starts with a NIO HTTP Ingress Connector. Then we have the String Appender processing element, then a Logger, next aAdd Transport Header element and finally NIO HTTP Egress Connector to send the message out. The flow is as follows.

string appender flow

The responsibility of the String Appender processing element is to append the integration flow name to the message id and store it as a scope variable. Logger is simply used to log the scope variable saved by the String Appender element. The Add New Header element is used to add the newly created string scope variable as a transport header. Configuration for the String Appender is shown below. Note that here we have used the advanced mode for the element.

string appender conf
In this topic
In this topic
Contact Us