Reputation: 25
This will probably be a layup for most of you, so I apologize in advance. I am using Apache camel with spring DSL. My message body has been converted to a string. I want everything from the 9th to 998th character, preferably using a simple expression. I have tried
<transform>
<simple>${body.substring(8,${body.length}-1)}</simple>
</transform>
but Camel doesn't recognize the subtraction. As such, it will try to convert the string "1045-2"
to an integer, and obviously fail. Is there a workaround here?
Upvotes: 2
Views: 13557
Reputation: 55750
Use groovy, javascript etc which is more powerful dynamic programming language
<groovy>request.body.substring(8, request.body.length-1)</groovy>
You need to add camel-groovy as a dependency together with groovy also.
Upvotes: 5
Reputation: 71
The following code snippet will work.
<transform>
<simple>${body.substring(8,${body.length()-1})}</simple>
</transform>
Upvotes: 6