Search code examples
apache-camel

Why I have to use ${body} instead of {{body}} in camel route definition


Camel documentation states that property placeholder uses the format {{prop_name}}, however the following route doesn't return the desired output if I define it as:

<route>
    <from uri="timer:test-timer?period=5000" />
    <setBody>
        <simple>Hello world!</simple>
    </setBody>
    <log message="Body: {{body}}" />
</route>

However, it works if defined as:

<route>
    <from uri="timer:test-timer?period=5000" />
    <setBody>
        <simple>Hello world!</simple>
    </setBody>
    <log message="Body: ${body}" />
</route>

Can anybody explain why property placeholder replacement doesn't work as documented in this case?

Thanks


Solution

  • I learn that the reason why {{body}} doesn’t work is because body is a Simple DSL property, which of course is only available in Simple DSL.

    {{key}} placeholders only work with explicitly defined properties.