osdir.com

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What route returns


Hi,

I notice that if I split body without referencing aggregation strategy,
like this: split().body()
route returns the message like it was before splitting.
However, if I reference aggregation strategy in a split call like
this: .split(body(),new AggrStrat())
then route returns the message after aggregation. However, if I want to do
further tasks in a route after aggregator, in which I reference the same
strategy as in a splitter,
such as for example unmarshalling the aggregated message from fixedlength
format and marshalling into json, although these tasks were properly done,
which I can verify by logging body, the REST route that is calling the
observed route still receives the aggregated fixedlength message format.
So, basically I see json printed in java console, but in postman or browser
I get fixedlength format.
Does that mean that I have to implement conversion from fixedlength to json
in aggregation strategy class, or there is still a way to do it
somehow in a route builder class?

The outline of my route is like this:

from(getDirectRouteId(id))
.routeId(id)
        .setBody(simple("original request message"))

.setHeader("CamelJmsDestinationName",constant("queue://QM_TEST/inputq?targetClient=1"))

.to(ExchangePattern.InOut,"websphere:queue:SYSTEM.DEFAULT.LOCAL.QUEUE?useMessageIDAsCorrelationID=true&replyTo=REPLYQ")
        .unmarshal(dataFormat)
        .split(body(),new AgrStrat()).parallelProcessing()
        .process(new Processor() {
            public void process(Exchange exchange) throws Exception {
            //assemble new mq requests based on the content of splitted
response mq message
           }
        })

.setHeader("CamelJmsDestinationName",constant("queue://QM_TEST/inputq?targetClient=1"))

.to(ExchangePattern.InOut,"websphere:queue:SYSTEM.DEFAULT.LOCAL.QUEUE?useMessageIDAsCorrelationID=true&replyTo=REPLYQ")
        .aggregate(constant(true),new AgrStrat()).completionTimeout(3000)
        .log("${body}")
        .unmarshal(dataFormat1)
        .marshal().json(JsonLibrary.Jackson)
        .log("${body}");

AgrStrat basically concatenates the newExchange with the oldExchange,
inserting "\n" in between, at the moment.
I guess I should move format conversion there? Thank you.