You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by FritzGerald <er...@gmx.de> on 2013/07/26 10:38:49 UTC

problem with aggregating multicast

Hello,

i'm new to camel and i'm having a problem using the multicast option. I
defined four beans that do some calculations. They receive the number 5 and
then 

add, subtract and so on. The 5 is being sent by the bean giveMeNumber.
The problem is that in the end I don't receive the result I expect.

This is how my route looks like:

	context.addRoutes(new RouteBuilder() {
			public void configure() {

				from("bean:giveMeNumber?method=giveNumber")
						.multicast()
						.parallelProcessing()

						.to("bean:add?method=calculate")
						.to("bean:subtract?method=calculate")
						.to("bean:multiply?method=calculate")
						.to("bean:divide?method=calculate")

				.aggregate(new MyAggregator()).body().completionSize(4)
				.to("bean:drucker?method=print");

			}
		});

All beans act on a Double. Do I need the "MyAggregator" to aggregate 4
Doubles or is this something Camel can do on its own ?

And there's my problem. If, for example, my bean "giveNumber" returns the
number 5 the output of the printer should be like "10 0 25 1" (because
5+5=10, 

5-5=0, 5*5=25, 5/5=1). But my output is "5 5 5 5". So it seems like my
aggregator isn't appended to my .to()-beans but to my from()-bean. Is there
a 

mistake in the route-definition or do you have any ideas what my problem
could be?

Thanks for your help,

FritzGerald



--
View this message in context: http://camel.465427.n5.nabble.com/problem-with-aggregating-multicast-tp5736283.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: problem with aggregating multicast

Posted by Bilgin Ibryam <bi...@gmail.com>.
Hi FritzGerald,

you have to say where does the multicast end, otherwise it will treat
aggregate as another destination for the multicast...

Add an  .end() before the .aggregate statement.
Have a look at the examples here http://camel.apache.org/multicast.html

Bilgin


On 26 July 2013 09:38, FritzGerald <er...@gmx.de> wrote:
> Hello,
>
> i'm new to camel and i'm having a problem using the multicast option. I
> defined four beans that do some calculations. They receive the number 5 and
> then
>
> add, subtract and so on. The 5 is being sent by the bean giveMeNumber.
> The problem is that in the end I don't receive the result I expect.
>
> This is how my route looks like:
>
>         context.addRoutes(new RouteBuilder() {
>                         public void configure() {
>
>                                 from("bean:giveMeNumber?method=giveNumber")
>                                                 .multicast()
>                                                 .parallelProcessing()
>
>                                                 .to("bean:add?method=calculate")
>                                                 .to("bean:subtract?method=calculate")
>                                                 .to("bean:multiply?method=calculate")
>                                                 .to("bean:divide?method=calculate")
>
>                                 .aggregate(new MyAggregator()).body().completionSize(4)
>                                 .to("bean:drucker?method=print");
>
>                         }
>                 });
>
> All beans act on a Double. Do I need the "MyAggregator" to aggregate 4
> Doubles or is this something Camel can do on its own ?
>
> And there's my problem. If, for example, my bean "giveNumber" returns the
> number 5 the output of the printer should be like "10 0 25 1" (because
> 5+5=10,
>
> 5-5=0, 5*5=25, 5/5=1). But my output is "5 5 5 5". So it seems like my
> aggregator isn't appended to my .to()-beans but to my from()-bean. Is there
> a
>
> mistake in the route-definition or do you have any ideas what my problem
> could be?
>
> Thanks for your help,
>
> FritzGerald
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/problem-with-aggregating-multicast-tp5736283.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: problem with aggregating multicast

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

The multicast has built-in aggregation so that is much easier to use.
So remove the aggregate from the route. And add the aggregation
strategy to the multicast directly.



On Fri, Jul 26, 2013 at 10:38 AM, FritzGerald <er...@gmx.de> wrote:
> Hello,
>
> i'm new to camel and i'm having a problem using the multicast option. I
> defined four beans that do some calculations. They receive the number 5 and
> then
>
> add, subtract and so on. The 5 is being sent by the bean giveMeNumber.
> The problem is that in the end I don't receive the result I expect.
>
> This is how my route looks like:
>
>         context.addRoutes(new RouteBuilder() {
>                         public void configure() {
>
>                                 from("bean:giveMeNumber?method=giveNumber")
>                                                 .multicast()
>                                                 .parallelProcessing()
>
>                                                 .to("bean:add?method=calculate")
>                                                 .to("bean:subtract?method=calculate")
>                                                 .to("bean:multiply?method=calculate")
>                                                 .to("bean:divide?method=calculate")
>
>                                 .aggregate(new MyAggregator()).body().completionSize(4)
>                                 .to("bean:drucker?method=print");
>
>                         }
>                 });
>
> All beans act on a Double. Do I need the "MyAggregator" to aggregate 4
> Doubles or is this something Camel can do on its own ?
>
> And there's my problem. If, for example, my bean "giveNumber" returns the
> number 5 the output of the printer should be like "10 0 25 1" (because
> 5+5=10,
>
> 5-5=0, 5*5=25, 5/5=1). But my output is "5 5 5 5". So it seems like my
> aggregator isn't appended to my .to()-beans but to my from()-bean. Is there
> a
>
> mistake in the route-definition or do you have any ideas what my problem
> could be?
>
> Thanks for your help,
>
> FritzGerald
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/problem-with-aggregating-multicast-tp5736283.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen