Hi Claus et al, I'd like to use a prototype bean in a route such that a new instance gets created at the beginning of the route, and that same instance is used throughout the route until the route ends.
Included below are two simple routes and a fragment of a service bean class that collects parts from various responses with external services. [This was somewhat addressed here: http://camel.465427.n5.nabble.com/Bean-s-scope-in-Camel-td5737137.html before, but not as fully as here.] Questions: -Is this a legitimate way of keeping state in routes with a service bean, or should I be using something else for this use case? -Are ROUTE1 and ROUTE2 completely equivalent? [If not, why?] -How can I make the same bean instance transfer to ROUTE3? -When will the prototype instance of myAwesomeBean terminate? Your help is much appreciated! Rick <beans> <bean id="myAwesomeBean" class="com.test.MyAwesomeBean" scope="prototype"/> <camelContext> <route id = "ROUTE1"> <from uri="direct:start"/> <to uri="myAwesomeBean:myBeanMethod1"/> <to uri="http://webService"/> <bean ref="myAwesomeBean" method="myBeanMethod2"/> <to uri="salesforce:doSomething" /> <bean ref="myAwesomeBean" method="myBeanMethod3"/> <to uri="direct:ROUTE3"> </route> <route id = "ROUTE2"> <from uri="direct:start"/> <to uri="myAwesomeBean:myBeanMethod1"/> <to uri="http://webService"/> <to uri="myAwesomeBean:myBeanMethod2"/> <to uri="salesforce:doSomething" /> <to uri="myAwesomeBean:myBeanMethod3"/> <to uri="direct:ROUTE3"> </route> <route id ="ROUTE3"> <from uri="direct:ROUTE3"/> <to uri="cxf:bean:someOtherService"/> <to uri="myAwesomeBean:myBeanMethod4"/> </route> </camelContext> <beans> public class MyAwesomeBean { private String somethingStoredBy_myBeanMethod1 = ""; private int somethingStoredBy_myBeanMethod2 = ""; private boolean somethingStoredBy_myBeanMethod3 = ""; private float somethingStoredBy_myBeanMethod4 = ""; } -- View this message in context: http://camel.465427.n5.nabble.com/to-bean-xxx-or-not-to-bean-xxx-Getting-clarity-on-bean-scope-tp5754593.html Sent from the Camel - Users mailing list archive at Nabble.com.