${header.timestampPart2.substri" /> ${header.timestampPart2.substri" /> ${header.timestampPart2.substri"/>

Is it possible to call the header value as a parameter for the method applied to the same object in simple interpreter, Spring DSL for Apache Camel?

427 views Asked by At

Is it possible to call something like this in Apache Camel's Spring DSL

 <setHeader headerName="timestampPart3"><simple>${header.timestampPart2.substring(0, ${header.timestampPart2.length()} - 2)}</simple></setHeader>

or like this

 <setHeader headerName="timestampPart3"><simple>${header.timestampPart2.substring(0, header.timestampPart2.length() - 2)}</simple></setHeader>

For the second attempt it identifies .length() - 2 as a single method name call

2

There are 2 answers

0
techtheist On BEST ANSWER

You can increment and decrement with simple, so...

I wouldn't recommend, but for example:

<setHeader headerName="timestampPart2_1">
    <simple>${header.timestampPart2.length()}--</simple>
</setHeader>

<setHeader headerName="timestampPart2_1">
    <simple>${header.timestampPart2_1}--</simple>
</setHeader>

<setHeader headerName="timestampPart3">
    <simple>${header.timestampPart2.substring(0, ${header.timestampPart2_1})}</simple>
</setHeader>
0
Eljah On

I had to use groovy instead of simple for doing that.

<setHeader headerName="timestampPart3"><groovy>
     request.headers.get('timestampPart2').split("\\.")[0]
     </groovy></setHeader>