1 Reply Latest reply on Oct 1, 2016 9:50 PM by Fatkhur Rokhman

    Camel's Content Based Routing, how to do substring on body using simple language?

    Fatkhur Rokhman Newbie

      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,