David Bremmen
David Bremmen

Reputation: 75

Camel - How to use an object that is inside the object sent on body to do splitting

Maybe this is a very dumb question but It will help to clarify my understanding of camel. I have a seda queue where I insert objects of type FromData. FromData has a method

public GenericFile<File> getFirstFile () {
    return files.values().iterator().next();
}

Now in my route I want read from the queue and split the contents of the file.

I came up with this solution. Are there a better way to refer to body.firstFile, other ways of doing .split(simple("${body.firstFile}"))

public void configure() {
    from("seda:processReceiver")
    .split(simple("${body.firstFile}"))
    .split(body().tokenize(",")).streaming()
    .process(new Processor() {
         public void process(Exchange msg) {
             System.out.println(msg.getIn().getBody());
         }
    });
} 

Upvotes: 1

Views: 536

Answers (1)

vikingsteve
vikingsteve

Reputation: 40378

This would suit:

.setBody(simple("${body.firstFile}"))

Upvotes: 1

Related Questions