You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ext2 <xu...@tongtech.com> on 2010/10/25 12:45:48 UTC
Why the route's result is not correct?
Hi:
Here is a simple route, I think it's result should be 6, but the result is
2;
from("direct:start2").multicast(new SumAggregateBean())
.pipeline().transform(BeanLanguage.bean(IncreaseOne.class)).bean(new
IncreaseTwo()).end()
.pipeline().transform(BeanLanguage.bean(IncreaseOne.class)).bean(new
IncreaseTwo()).end()
.end()
.to("mock:result2");
In this route, IncreaseOne just add the input by one, IncreaseTwo: just add
the input by two; The SumAggregateBean just add sum the input integer.
If I send number 0 to the route, I think each pipe line 's result should be
0+1+2=3, and final result of route should be 3+3=6; but the result is 2;
Why? Is it a bug?
Following is the source code of IncreaseOne, IncreaseTwo, and
SumAggregateBeans;
public static class IncreaseOne{
public int increase(int v)
{
return v+1;
}
}
public static class IncreaseTwo{
public int increase(int v) {
return v+2;
}
}
public static class SumAggregateBean implements AggregationStrategy{
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
if(oldExchange == null)
return newExchange;
int v = parseInt(newExchange.getIn().getBody()) +
parseInt(oldExchange.getIn().getBody());
newExchange.getIn().setBody(v);
return newExchange;
}
}
Re: Why the route's result is not correct?
Posted by Claus Ibsen <cl...@gmail.com>.
I have created a ticket
https://issues.apache.org/activemq/browse/CAMEL-3276
If you use a transform on both beans then it should work.
Will get this fixed in the next release.
On Mon, Oct 25, 2010 at 4:49 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Is it in purpose you dont have a 2nd transform in the pipeline?
>
>
>
> On Mon, Oct 25, 2010 at 12:45 PM, ext2 <xu...@tongtech.com> wrote:
>> Hi:
>>
>> Here is a simple route, I think it's result should be 6, but the result is
>> 2;
>>
>>
>>
>> from("direct:start2").multicast(new SumAggregateBean())
>>
>> .pipeline().transform(BeanLanguage.bean(IncreaseOne.class)).bean(new
>> IncreaseTwo()).end()
>>
>> .pipeline().transform(BeanLanguage.bean(IncreaseOne.class)).bean(new
>> IncreaseTwo()).end()
>>
>> .end()
>>
>> .to("mock:result2");
>>
>>
>>
>>
>>
>> In this route, IncreaseOne just add the input by one, IncreaseTwo: just add
>> the input by two; The SumAggregateBean just add sum the input integer.
>>
>> If I send number 0 to the route, I think each pipe line 's result should be
>> 0+1+2=3, and final result of route should be 3+3=6; but the result is 2;
>>
>>
>>
>> Why? Is it a bug?
>>
>>
>>
>> Following is the source code of IncreaseOne, IncreaseTwo, and
>> SumAggregateBeans;
>>
>>
>>
>>
>>
>>
>>
>> public static class IncreaseOne{
>>
>> public int increase(int v)
>>
>> {
>>
>> return v+1;
>>
>> }
>>
>> }
>>
>> public static class IncreaseTwo{
>>
>> public int increase(int v) {
>>
>> return v+2;
>>
>> }
>>
>> }
>>
>>
>>
>> public static class SumAggregateBean implements AggregationStrategy{
>>
>> public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
>>
>> if(oldExchange == null)
>>
>> return newExchange;
>>
>> int v = parseInt(newExchange.getIn().getBody()) +
>>
>> parseInt(oldExchange.getIn().getBody());
>>
>> newExchange.getIn().setBody(v);
>>
>> return newExchange;
>>
>> }
>>
>> }
>>
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Why the route's result is not correct?
Posted by Claus Ibsen <cl...@gmail.com>.
Is it in purpose you dont have a 2nd transform in the pipeline?
On Mon, Oct 25, 2010 at 12:45 PM, ext2 <xu...@tongtech.com> wrote:
> Hi:
>
> Here is a simple route, I think it's result should be 6, but the result is
> 2;
>
>
>
> from("direct:start2").multicast(new SumAggregateBean())
>
> .pipeline().transform(BeanLanguage.bean(IncreaseOne.class)).bean(new
> IncreaseTwo()).end()
>
> .pipeline().transform(BeanLanguage.bean(IncreaseOne.class)).bean(new
> IncreaseTwo()).end()
>
> .end()
>
> .to("mock:result2");
>
>
>
>
>
> In this route, IncreaseOne just add the input by one, IncreaseTwo: just add
> the input by two; The SumAggregateBean just add sum the input integer.
>
> If I send number 0 to the route, I think each pipe line 's result should be
> 0+1+2=3, and final result of route should be 3+3=6; but the result is 2;
>
>
>
> Why? Is it a bug?
>
>
>
> Following is the source code of IncreaseOne, IncreaseTwo, and
> SumAggregateBeans;
>
>
>
>
>
>
>
> public static class IncreaseOne{
>
> public int increase(int v)
>
> {
>
> return v+1;
>
> }
>
> }
>
> public static class IncreaseTwo{
>
> public int increase(int v) {
>
> return v+2;
>
> }
>
> }
>
>
>
> public static class SumAggregateBean implements AggregationStrategy{
>
> public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
>
> if(oldExchange == null)
>
> return newExchange;
>
> int v = parseInt(newExchange.getIn().getBody()) +
>
> parseInt(oldExchange.getIn().getBody());
>
> newExchange.getIn().setBody(v);
>
> return newExchange;
>
> }
>
> }
>
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Why the route's result is not correct?
Posted by Hadrian Zbarcea <hz...@gmail.com>.
Hi,
I saw your previous mail, and from what you are saying the result seems to be incorrect.
We are now trying to get the 2.5.0 release out. Will take a look as soon as I am done with the release.
Thanks for the patience and for using camel,
Hadrian
On Oct 25, 2010, at 6:45 AM, ext2 wrote:
> Hi:
>
> Here is a simple route, I think it's result should be 6, but the result is
> 2;
>
>
>
> from("direct:start2").multicast(new SumAggregateBean())
>
> .pipeline().transform(BeanLanguage.bean(IncreaseOne.class)).bean(new
> IncreaseTwo()).end()
>
> .pipeline().transform(BeanLanguage.bean(IncreaseOne.class)).bean(new
> IncreaseTwo()).end()
>
> .end()
>
> .to("mock:result2");
>
>
>
>
>
> In this route, IncreaseOne just add the input by one, IncreaseTwo: just add
> the input by two; The SumAggregateBean just add sum the input integer.
>
> If I send number 0 to the route, I think each pipe line 's result should be
> 0+1+2=3, and final result of route should be 3+3=6; but the result is 2;
>
>
>
> Why? Is it a bug?
>
>
>
> Following is the source code of IncreaseOne, IncreaseTwo, and
> SumAggregateBeans;
>
>
>
>
>
>
>
> public static class IncreaseOne{
>
> public int increase(int v)
>
> {
>
> return v+1;
>
> }
>
> }
>
> public static class IncreaseTwo{
>
> public int increase(int v) {
>
> return v+2;
>
> }
>
> }
>
>
>
> public static class SumAggregateBean implements AggregationStrategy{
>
> public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
>
> if(oldExchange == null)
>
> return newExchange;
>
> int v = parseInt(newExchange.getIn().getBody()) +
>
> parseInt(oldExchange.getIn().getBody());
>
> newExchange.getIn().setBody(v);
>
> return newExchange;
>
> }
>
> }
>