I think what jeremy meant is that if you add a mutable object (like a bean with setters and getters (or a list but see below)) to the exchange before the multicast, each of the exchanges in the multicast will be shallow copies of the original exchange, this means that they will all contain this object (the same instance). This means that it is possible to have some common data in the exchanges for that. However if the multicast is parallel (multiple threads) all the methods you are calling in the multicast must be thread safe (which is not the case for normal list objects).
The common bean approach does of course also work, but here you have one bean per camel-context, which means that all invocations of the route will share the data (which may or may not be what you want). Best regards Stephan -----Original Message----- From: Rohan Emmanuel <rohan.emmanue...@gmail.com> Sent: Tuesday, 1 March 2022 09:44 To: users@camel.apache.org Subject: Re: sharing exchange properties in mutlicast route The Exchange properties won't be visible as the sub-routes would have different exchange objects. I have verified this by checking the exchange IDs and they were different in each sub-routes.. The exchange properties set in one sub route when accessed on other sub-routes returned null. am I missing anything? As suggested by Claus, I created a common bean to store the data required, which I am accessing in each of the routes. On Tue, Mar 1, 2022 at 12:57 AM Jeremy Ross <jeremy.g.r...@gmail.com> wrote: > You could also set a map instance in a header or exchange property and > any of the changes to map entries would be visible across sub routes > and siblings. > > On Fri, Feb 25, 2022 at 8:04 PM Rohan Emmanuel > <rohan.emmanue...@gmail.com > > > wrote: > > > Thank you Claus so much for your quick reply.Much appreciated. > > > > On Fri, 25 Feb 2022, 7:57 pm Claus Ibsen, <claus.ib...@gmail.com> wrote: > > > > > Hi > > > > > > That is not possible as the design when using multicast is that > > > the exchange are independent. > > > If you need to share some data then use an external shared bean > > > you can access from the multicased sub routes. > > > > > > > > > On Fri, Feb 25, 2022 at 1:26 PM Rohan Emmanuel > > > <rohan.emmanue...@gmail.com> wrote: > > > > > > > > Hi , > > > > I am using multicast in my route like mentioned below. > > > > i am setting a property in one of these routes with id route2, > > > > which > i > > > want > > > > to access in the multicast route1. i see that the exchange > > > > property > is > > > null > > > > in the route1. > > > > can you please let me know how can i achieve this? > > > > > > > > > > > > > > > > <route id="route1"> > > > > <multicast stopOnException="true"shareUnitOfWork="true> > > > > > > > > <to uri="direct:organisation_endpoin.dest1"/> > > > > > > > > <to uri="direct:organisation_endpoint.dest2"/> > > > > > > > > </multicast> > > > > <log message="main route ${exchangeProperty.testprop} ." /> > > > > </route> > > > > > > > > > > > > <route if="route2"> > > > > <from uri="direct:organisation_endpoint.dest1"/> > > > > <setProperty name="testprop"> > > > > <simple>hello</simple> > > > > </setProperty> > > > > </route> > > > > > > > > > > > > <route id="route3"> > > > > <from uri="direct:organisation_endpoint.dest2"/> > > > > </route> > > > > > > > > -- > > > > Regards, > > > > Rohan Emmanuel > > > > > > > > > > > > -- > > > Claus Ibsen > > > ----------------- > > > https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fd > > > avsclaus.com%2F&data=04%7C01%7Cstephan.siano%40sap.com%7C8c0f7 > > > aeea7664a79964608d9fb5fc1ce%7C42f7676cf455423c82f6dc2d99791af7%7C0 > > > %7C0%7C637817210965214736%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw > > > MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdat > > > a=TSzMrXfX9nb%2B8aIhwk65cOVdxJi40HtfXY9ILoug4JQ%3D&reserved=0 > > > @davsclaus Camel in Action 2: > > > https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.manning.com%2Fibsen2&data=04%7C01%7Cstephan.siano%40sap.com%7C8c0f7aeea7664a79964608d9fb5fc1ce%7C42f7676cf455423c82f6dc2d99791af7%7C0%7C0%7C637817210965214736%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=l0HKWzCuUSPxPpcqRfxsCpl5gf%2BWt8%2FYIaOuzbBLf9A%3D&reserved=0 > > > > > > -- Regards, Rohan Emmanuel