A constant is a one time constant. So if you want a new instance, you need to use a bean or process and return a newly created instance
On Wed, Mar 15, 2017 at 12:23 PM, ayman.elshayb <ayman.elsh...@gmail.com> wrote: > Hello All, > > I have a problem . I have a sub router . The router get in the body an > object with type x then i need to convert x to y then i need to do series > of changes to x and return back x . To do this , i have done the following > DSL > > > from("direct:Subrouter").setExchangePattern(ExchangePattern.InOut) > .setHeader(ORGINAL_ENTITY,body()).setBody().constant(new Y()) > > .bean(changeYbean,"transform"); > > The problem is that ".setBody().Constant(new Y())" adds extra object each > time the router is called by new X and did not forget the old Y so in the > end i got a list of Ys > > For example if the subrouter is called 4 times each time with new X . the > last called will return List of Y not one Y > > Note: i use spring boot as bean context and i need Y object for each call > > Thanks, > Ayman El Shayeb > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/I-need-to-set-Body-by-new-Pojo-each-time-the-router-called-tp5795518.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2