multicast and setting header

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

multicast and setting header

Tyler Durvik
I have a group of processors that I am sending messages to via
multicast.  Each processor will add a header to the message based on
the what the processor needs to do.  The problem is that not all
headers are in the message after the multicast has completed.   I have
the multicast set to parallelprocessing=true, so I am not sure if this
makes the exchange read-only maybe.
Reply | Threaded
Open this post in threaded view
|

Re: multicast and setting header

ychawla
Hi Tyler,
Are some of the headers in there but not all of them?  If you want, you can use an aggregator with the multicast and set a custom aggregation strategy:

http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/aggregate/AggregationStrategy.html

This way you can process each exchange in the multicast, grab your headers, and see them on the new exchange.  See the multicast page for more details on a custom aggregator:

http://camel.apache.org/multicast.html

Thanks,
Yogesh
Reply | Threaded
Open this post in threaded view
|

Re: multicast and setting header

Claus Ibsen-2
Hi

Yogesh is right when he suggest to use the aggregation strategy of the
multicast. This allows you full  control of the assembly of the
outgoing message when all the parallel multicasted messages is
complete.

By default the multicast will just keep the last message as the
outgoing message. (eg the UseLatestAggregationStrategy)




On Tue, May 8, 2012 at 5:10 AM, ychawla <[hidden email]> wrote:

> Hi Tyler,
> Are some of the headers in there but not all of them?  If you want, you can
> use an aggregator with the multicast and set a custom aggregation strategy:
>
> http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/processor/aggregate/AggregationStrategy.html
>
> This way you can process each exchange in the multicast, grab your headers,
> and see them on the new exchange.  See the multicast page for more details
> on a custom aggregator:
>
> http://camel.apache.org/multicast.html
>
> Thanks,
> Yogesh
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/multicast-and-setting-header-tp5691098p5692642.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Reply | Threaded
Open this post in threaded view
|

Re: multicast and setting header

emeka_kanu
In reply to this post by Tyler Durvik
Hello Tyler,

Did you ever fix this problem?

I'm having an issue as well, for which I have implemented the AggregationStrategy but am still facing issues.

Please see the URL below for more details.

http://fusesource.com/forums/thread.jspa?threadID=3942&tstart=0

Thank you for any help you can provide.

Kind Regards
Emeka Kanu
Reply | Threaded
Open this post in threaded view
|

Re: multicast and setting header

hekonsek
> I'm having an issue as well, for which I have implemented the
> AggregationStrategy but am still facing issues.

This is how you can collect exchanges multicasted to the several endpoints.

from("direct:multicastMe")
  .multicast(new GroupedExchangeAggregationStrategy()).parallelProcessing()
    .to("bean:processor1").to("bean:processor2")
  .end().
.setBody(property(Exchange.GROUPED_EXCHANGE));

Now you end up with a message which body consists of a List of
messages collected from the multicast endpoints (or processors).

--
Henryk Konsek
http://henryk-konsek.blogspot.com
Reply | Threaded
Open this post in threaded view
|

Re: multicast and setting header

emeka_kanu
Thank you Henryk,

Your solution has worked for me.

Note: I had to get the original exchange from inside one of the returned (multicast) exchanges to get the original headers and make sure they were preserved.

This was done inside a Processor implementation.

Once again, thank you

Regards,
Emeka Kanu