[ https://issues.apache.org/activemq/browse/CAMEL-2650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58901#action_58901 ]
Claus Ibsen commented on CAMEL-2650: ------------------------------------ Using @Produce or other Camel injected services will not consider singleton or prototype scope beans. For prototype scoped a WARN is logged about the need to manually stop the service after usage." trunk: 934731. > @Produce and @Consume injected on prototype beans needs a mechanism for > automatic stopping when no longer in use > ---------------------------------------------------------------------------------------------------------------- > > Key: CAMEL-2650 > URL: https://issues.apache.org/activemq/browse/CAMEL-2650 > Project: Apache Camel > Issue Type: Improvement > Components: camel-spring > Affects Versions: 2.2.0 > Reporter: Claus Ibsen > Assignee: Claus Ibsen > Fix For: Future > > > This only applies for prototype scoped POJOs which uses @Produce or @Consume > to inject a Camel Producer/Consumer. > As the prototype scoped POJO is short lived and there could potentially be > created many of those POJOs. > Then @Produce / @Consume will inject new instances of Producer / Consumer as > well. > And since there is no standard way of knowing when the POJO is no longer in > need, which is where we can to stop the Producer/Consumer. > For singleton scoped this is not a problem as CamelContext will keep track on > the created Producer/Consumer in its internal _servicesToClose_. > Which is then stopped when CamelContext stops. > For prototype we need a different strategy such as > - proxy it to use pooled producers/consumers which CamelContext manage the > lifecycle > - use a shared ProducerTemplate / ConsumerTemplate instead which CamelContext > manages the lifecycle > - other > - maybe some thread local tricks -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira