Hi All,
I'm new to camel based application development.
how can i do substring on body using sample language in camel routing?
Let say I have message in activemq queue, named queue.data.raw.
here is sample message i want to process,
XXX|20160129|194720|00000013|4|SX |SAMPLE CAPITAL | |0|˜ |
I want to get character at 29th (zero based index), it is 4 that represents record type.
from("activemq:queue.data.raw?disableReplyTo=true")
.convertBodyTo(java.lang.String.class)
.choice()
.when().simple("${body.substring(29,1)} == '2'") //error
.to("activemq:queue.data.trade?disableReplyTo=true")
.log("Added to 'Trade queue'")
.when().simple("${body.substring(29,1)} == 'B'") //error
.to("activemq:queue.data.marketdepth?disableReplyTo=true")
.log("Added to 'Market Depth queue'")
.otherwise()
.log("not processed'")
.end()
.wireTap("stream:out")
.log("Processing of ${body} done.");
Thanks,
My mistake, the problem is on substring index.
it must be body.substring(29,30) instead of body.substring,(29,1).
Resolved now.
Thanks,