0% found this document useful (0 votes)
356 views7 pages

Kap 01 - Concepts and Use of Content Modifier

Basic concepts and know how

Uploaded by

Ilirian Rexho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
356 views7 pages

Kap 01 - Concepts and Use of Content Modifier

Basic concepts and know how

Uploaded by

Ilirian Rexho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Content Modifier to add/change/delete some data

Content Modifier is simple but one of most important step in CPI that used frequently
the key takeaways for practical CPI usage are:

a) Pipeline concept that CPI pass message contain headers, properties and body
from one CPI step to the next step, connected by arrows. Multiple CPI steps can be
chained together sequentially / parallelly.

b) Content Modifier able to add/change/delete headers, properties and body (also


number range & variables).

c) Generally, header store smaller size data that might need send to
receiver(s)a. E.g. as HTTP headers.

d) Generally, property store larger size data and data need to store in earlier step of
i-flow and need retrieve back at later step.

e) Body is main payload that can send to receiver(s).

Use of Content Modifier:


- You use the content modifier step to modify the content of incoming message
by providing additional information in the header or body of the message.
- Select one of the tabs Message Header, Message Body, or Exchange
Property. If modifying the Message Body, you can enter the data you want to
add to the message body in an editor. If modifying the Message Header or
the Exchange Property, you can define how to access the content of the
incoming message (which is then used to change the selected data container).
For example, in the Source Type, select XPath to specify an XPath expression
that addresses a particular element in the incoming message, which will be used
to change the message header.

Content Modifier Attributes for Message Header or Exchange Property

Attribute Description

Action You can specify whether the Content Modifier should create or
delete the header or property defined by the table row.

You must specify the name of the header or property you want to
delete.
Content Modifier Attributes for Message Header or Exchange Property

Attribute Description

Name Name under which the specified data has to be stored in the
selected header or property data container.

Source Type Indicates the kind of data you want to use to change the content of
the selected header or property data container.

You can select from the following types:

▪ Constant

Allows you to write a constant value to the header or


property data container.

Special characters like {} and [] are not allowed.

▪ Header

Allows you to specify the name of a Camel header. You

can then use this header to dynamically define


properties in subsequent steps.

To enter a header, select header in the Type column and in


the Value column choose Select to browse for predefined
headers.

▪ XPath

Allows you to retrieve data from the incoming message


using XML Path Language (XPath). For example, if you
have selected this type, you can specify the
following Value to point to an
element customerName in the incoming
message: /Order/Customer/CustomerNumber.
Content Modifier Attributes for Message Header or Exchange Property

Attribute Description

To enter XPath, select XPath in the Type column and in


the Value column choose Select to browse for
predefined xpath listed in wsdl of SOAP adapter for the
sender.
▪ Expression

Allows you to enter a Camel Simple Expression Language


expression (see http://camel.apache.org/simple.html ).

For example, you can use the


expression ${exchangeId} to add the exchange ID (a
unique identifier of the message exchange) to a data
container.

For more information on using Simple Expression


Language, see Using Camel Simple Expression
Language.
▪ Property

Allows you to specify an exchange property.

To enter a property, select property in the Type


column and define a value based on the selected value
type.
▪ External Parameter

This option is not available in WebUI but for


compatibility, reasons we still support content using
this field.

Integration developer can use externalization and


externalize any type of headers or exchange
properties.
Content Modifier Attributes for Message Header or Exchange Property

Attribute Description

Please refer to Externalize Parameters of an Integration


Flow for more details.

▪ Local Variable

Allows you to define a local variable and write its value at


runtime to the header or property data container. The value
can then be evaluated in subsequent steps of the integration
flow.

A local variable can be used in the context of the


integration flow.

▪ Number Range

Allows you to retrieve the value (a unique identifier) of a


predefined number range.

For more information on adding number range, see


Managing Number Ranges.

▪ Global Variable

Allows you to define a global variable and to write its value at


runtime to the header or property data container.

A local variable can be used across different integration


flows of the same tenant.

Source Value Value of the property

Data Type Valid Java data type


Content Modifier Attributes for Message Header or Exchange Property

Attribute Description

The Data Type column is used only for the


types XPath and Expression. The data type can belong to any
Java class. For example, if you are addressing a string-type
element, enter java.lang.String as the Java data type. For more
information about supported data types,
see
ht tpsu:/a/cgaem
lang .hetml
l.apac
. he.org/components/latest/languages/simple -

Default Value If you have selected Local Variable or Global Variable as Type,
the value specified as Default will be assigned to the header
(Only relevant if
value if the variable is not found at runtime.
you have
selected Local
Variable or Global
Variable as Type)

- Go to the Message Body tab, and define the fields as shown below.

Attribute Description

Type The default value is Expression. If the payload contains expressions


within it, then set the type as Expression; if the payload is huge and it has
no expressions within it, then it is recommended to use the type Constant.

Body Enter the content expected in the outgoing message.


Remember
Ensure that you set a placeholder for the existing header information.

▪ If you add a Content Modifier step without a header, body, and property, you
cannot trace the element.
Example
Let us assume that the incoming message contains the following information content:

<product>
<productId>HT-1051</productId>
<productName>Deskjet Mobile</productName>
</product>

The message contains information about an individual product from a product catalog.

The use case is that this message is to be enriched with the actual system time (as
order time) and transferred into an order message.

In a first content modifier, specify the following settings in the Exchange Property tab:

Parameter Value

Name timestamp

Type Expression

Data Type java.lang.String

Value ${date:now:yyyy-MM-dd HH:mm:ss}

Using the expression ${date:now:yyyy-MM-dd HH:mm:ss}, at runtime the actual


system time is retrieved from the system.

The content modifier stores the time value in the timestamp property.

In a 2nd content modifier, enter the following expression in the Message Body tab:

<order>
<time>${property.timestamp}</time>
${in.body}
</order>
At runtime, the expression ${property.timestamp} dynamically retrieves the
timestamp stored in the previous content modifier.

The expression ${in.body} is replaced by the actual content of the inbound message.

As a result, the final message (after the 2 content modifiers) has the following
content for our example:

<order>
<time>2021-05-19 09:20:56</time>
<product>
<productId>HT-1051</productId>
<productName>Deskjet Mobile</productName>
</product>
</order>

In the Message Body, you can do the following:

1. Call the Header Elements, like:

${header.elementname}

2. Call the Property Elements, like:

${property.elementname}

3. Call the body of the previous Content Modifier, like:

${in.body}

You might also like