Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Won't Fix
-
2.2.0
-
None
Description
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