javaapache-camelcamel-spring-dsl

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?


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


Solution

  • 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>