Search code examples
javaspring-bootcollectionsapache-camelspring-camel

How Camel split/iterate over the list and send to queue individually?


I am new to camel, unable to figure out sending individual entity out of list to queue.

private void addIncomingFixMessageRoute() {     
    from(Endpoints.FIX_MESSAGE_IN_ROUTE)
    .routeId("IncomingFixMessageRoute")
    .bean(fixMessageTransformer, "transform")
    .marshal().json()
    .to("activemq:queue:feed");
}

Here the transform method of the bean fixMessageTransformer returns List<String>, now I want to apply splitter which iterates and send each element to queue individually. Unable to figure out how I would achieve it.

Tried by applying .split().tokenize(), but no luck.


Solution

  • Just add the splitter on the body, and it will split it.

     .split(body())
       ...