How to use mappings in routes

Learn how to use mappings in routes.


The Mappings are called by the tnd-absorption component that can only be used as producer :

<to uri="tnd-absorption..." />

URI format




You can also specify the name of the Mapping in the header tnd-absorption-mapping-name, it will be used when the syntax of the URI is tnd-absorption:dynamic. This is particularly useful when grouping absorptions.

URI options

Name Default value Description
wait false Whether or not the call to the Mapping should block until the absorption is complete


How to define the parameter values of the mapping

Without expressions in mapping

This is the recommended usage

If the Mapping has no expression defined for a parameter then it expects to find its value into a Map in the exchange body.

   <from uri="direct:payment" />
           <u:map-entry key="paymentId">
           <!-- Other key/values -->
   <to uri="tnd-absorption:absorbPayment" />

See How to use Camel utilities in routes for explanation of <u:map-create> and <u:setMapValue> that helps managing the map.

With expressions in mapping

This is the legacy behavior

In this case, the way to retrieve the values are defined in the mapping itself in the expressions of the parameters.

Absorb payments without waiting for the absorption to be complete

It's the fastest solution, it doesn't wait until the absorption is complete therefore new payments can be processed and transformed in the meantime.

   <from uri="direct:payment" />
   <to uri="tnd-absorption:absorbPayment" />
   <!-- At this point a request to this payment will most likely return nothing -->

Absorb customer with absorption blocking the exchange processing (synchronous)

You won't be able to process new customer in this route until this operation is complete but you will be certain the customer queriable from that point on

    <from uri="direct:customer" />
    <to uri="tnd-absorption:absorbCustomer?wait=true" />
    <!-- At this point a request to this customer will always return it -->

Define the name of the mapping at runtime

Sometimes, you want to call on mapping or another depending of a particular state

    <from uri="absorbPayment"/>
    <!-- Select the proper Mapping -->
            <setHeader name="tnd-absorption-mapping-name">
            <setHeader name="tnd-absorption-mapping-name">
    <!-- Call the proper Mapping -->
    <to uri="tnd-absorption:dynamic"/>

Related Links