Overview
Beyond <body> and <groovy>, Integration Manager mapper definitions support <constant>, <simple>, <header>, and <property> expression types. These let you inject static values, evaluate Camel Simple Language expressions, or pull values from message headers and exchange properties directly into mapped fields.
Complete XML Examples
Constant Values
Use <constant> to set a fixed, hardcoded value on every mapped record:
<mappers>
<loadMapper id="constantMapper">
<body in="sku"/>
<body in="elasticity" out="attribute1"/>
<!-- Every record gets the same "name" value -->
<constant expression="Elasticity" out="name"/>
<!-- Static country code -->
<constant expression="US" out="attribute2"/>
<!-- Static version marker -->
<constant expression="v2.1" out="attribute3"/>
</loadMapper>
</mappers>
Simple Language Expressions
Use <simple> for Camel Simple Language, which can reference body fields, headers, and properties:
<mappers>
<loadMapper id="simpleExpressionMapper">
<body in="sku"/>
<!-- Access a body field using Simple syntax -->
<simple expression="${body[price]}" out="attribute1"/>
<!-- Reference an exchange property -->
<simple expression="${exchangeProperty:batchName}" out="name"/>
<!-- Static string via Simple (equivalent to constant) -->
<simple expression="Company" out="attribute2"/>
<!-- Combine header and body values -->
<simple expression="${header.region}-${body[sku]}" out="attribute3"/>
</loadMapper>
</mappers>
Header Values
Use <header> to pull a value directly from a Camel message header:
<mappers>
<loadMapper id="headerMapper">
<body in="sku"/>
<body in="label"/>
<!-- Stamp each record with the source file name from the header -->
<header expression="CamelFileName" out="attribute1"/>
<!-- Stamp with a custom header set earlier in the route -->
<header expression="importBatchId" out="attribute2"/>
</loadMapper>
</mappers>
Exchange Property Values
Use <property> to pull a value from an exchange property:
<mappers>
<loadMapper id="propertyMapper">
<body in="sku"/>
<body in="attribute1"/>
<body in="attribute2"/>
<!-- Set from an exchange property defined in the route -->
<property expression="Costs" out="name"/>
<!-- Use the current route ID as a tag -->
<property expression="CamelRouteId" out="attribute3"/>
</loadMapper>
</mappers>
Combining All Expression Types
<mappers>
<loadMapper id="combinedMapper">
<!-- Direct field copy -->
<body in="sku"/>
<body in="name" out="label"/>
<!-- Static value -->
<constant expression="PRODUCT" out="attribute1"/>
<!-- Simple expression referencing body -->
<simple expression="${body[price]}" out="attribute2"/>
<!-- Header value -->
<header expression="sourceSystem" out="attribute3"/>
<!-- Exchange property -->
<property expression="runDate" out="attribute4"/>
<!-- Groovy for complex logic -->
<groovy expression="body.category?.toUpperCase() ?: 'UNCATEGORIZED'" out="attribute5"/>
</loadMapper>
</mappers>
How It Works
-
<constant>-- injects a static string value. Theexpressionattribute contains the literal value. Evaluated once and applied identically to every record. -
<simple>-- evaluates a Camel Simple Language expression. Supports${body[field]},${header.name},${exchangeProperty:name}, and other Simple constructs. -
<header>-- reads the named message header directly. Theexpressionattribute is the header name (not a Simple expression). -
<property>-- reads the named exchange property directly. Theexpressionattribute is the property name. -
All expression types support the
outattribute to specify the target field name.
Common Pitfalls
-
<simple>vs<constant>:<simple expression="Company" out="name"/>and<constant expression="Company" out="name"/>both produce the static string "Company". However,<simple>is evaluated as a Simple expression each time, so if your string accidentally contains${...}, it will be interpreted. Use<constant>for truly static values. -
Header/property not set: If the referenced header or property does not exist at the time the mapper runs, the output field will be null. Ensure your route sets these values before the mapper step.
-
Simple expression syntax: Body field access in Simple uses
${body[fieldName]}(bracket notation). Dot notation (${body.field}) does not work for Map-based bodies. -
XML special characters: In
<simple>expressions, use&for&,<for<, and>for>since the expression is inside an XML attribute.