You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tomasz Domzal <ca...@rej.tomasz.domzal.pl> on 2009/03/08 13:35:07 UTC
Simple split / aggregate scenario - help me understand what's wrong
Hi,
Simple test case. Please tell me why splitting and
aggregating doesn't work I would expect it would ?
Maybe my understanding of split/aggregate is wrong ?
DSL route:
from("direct:start")
.splitter(body().tokenize(","), false)
.aggregator(header("type"), joinBodyWithColon).batchTimeout(500)
.to("mock:stop");
where joinBodyWithColon aggregation strategy just joins
messsages bodies with colon separator:
private final AggregationStrategy joinBodyWithColon = new AggregationStrategy() {
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
oldExchange.getIn().setBody(
oldExchange.getIn().getBody(String.class)+
":"+
newExchange.getIn().getBody(String.class));
return oldExchange;
}
};
after sending
template.sendBodyAndHeader(
"direct:start", ExchangePattern.InOnly,
"red,green,blue",
"type", "sometype");
endpoint "mock:stop" receives 1 message with body "red,green,blue"
while in my opinion it should receive 1 message with body "red:gree:blue".
BTW. When I insert direct endpoint between split end aggregate
elements - it works as expected.
Below route passes "red:green:blue" to mock endpoint:
from("direct:start")
.splitter(body().tokenize(","), false)
.to("direct:foo");
from("direct:foo")
.aggregator(header("type"), joinBodyWithColon).batchTimeout(500)
.to("mock:stop");
Thanks in advance
Tomek
Re: Simple split / aggregate scenario - help me understand what's
wrong
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Could you check this related topic?
http://www.nabble.com/routing-like-%22jetty-splitter-aggregator-reply%22-request-response-problem-td22374696s22882.html
On Sun, Mar 8, 2009 at 1:35 PM, Tomasz Domzal
<ca...@rej.tomasz.domzal.pl> wrote:
> Hi,
>
> Simple test case. Please tell me why splitting and
> aggregating doesn't work I would expect it would ?
> Maybe my understanding of split/aggregate is wrong ?
> DSL route:
>
> from("direct:start")
> .splitter(body().tokenize(","), false)
> .aggregator(header("type"), joinBodyWithColon).batchTimeout(500)
> .to("mock:stop");
>
> where joinBodyWithColon aggregation strategy just joins
> messsages bodies with colon separator:
>
> private final AggregationStrategy joinBodyWithColon = new AggregationStrategy() {
> public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
> oldExchange.getIn().setBody(
> oldExchange.getIn().getBody(String.class)+
> ":"+
> newExchange.getIn().getBody(String.class));
> return oldExchange;
> }
> };
>
>
> after sending
>
> template.sendBodyAndHeader(
> "direct:start", ExchangePattern.InOnly,
> "red,green,blue",
> "type", "sometype");
>
> endpoint "mock:stop" receives 1 message with body "red,green,blue"
> while in my opinion it should receive 1 message with body "red:gree:blue".
>
> BTW. When I insert direct endpoint between split end aggregate
> elements - it works as expected.
> Below route passes "red:green:blue" to mock endpoint:
>
> from("direct:start")
> .splitter(body().tokenize(","), false)
> .to("direct:foo");
>
> from("direct:foo")
> .aggregator(header("type"), joinBodyWithColon).batchTimeout(500)
> .to("mock:stop");
>
> Thanks in advance
> Tomek
>
>
>
>
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/