> This is a catch-22 situation. When using @Producer or @Consume etc.
> you are creating a Producer/Consumer up front.
> However you also want to stop the @Producer / @Consumer again when you
> are shutting down, or more ideally before if the POJO was no longer in
> use.
>
> However there is no nice API for doing that, so either we could just
> omit the stop and then risk having resources leaked as they are not
> properly stopped.
>
> If you look in the CamelPostProcessorHelper in camel-core in the
> #startService method.
> Its the one which "registers" it in CamelContext (servicesToClose).
>
> We can obviously change that to not do so but just start the service
> with registering.
> But again then we loose the ability to close it.
>
> Any thoughts?
>
Could you leverage lifecycle callbacks in Spring?
http://static.springsource.org/spring/docs/3.0.1.RELEASE/reference/html/beans.html#beans-factory-lifecycle-disposablebean
If @EndpointInject or @Produce create a ProducerTemplate and PT then
registers/starts its Producer(s) with CamelContext.addService, it seems
appropriate that as part of the lifecycle, when the PT's containing bean is
torn down, a destruction callback should be responsible for stopping any
Producers associated with the PT and de-registering them with the
CamelContext. Right now, initialization is automatic but there is no
corresponding de-initialization being done.
Though this might mean that you need a Spring-specific
DefaultProducerTemplate subclass (or some other Spring-specific
implementation of ProducerTemplate) that is lifecycle-aware, since DPT still
needs to be usable without Spring.
Matt
--
View this message in context:
http://old.nabble.com/Injecting-ProducerTemplates%2C-scoping%2C-and-JMX-memleak-tp28219199p28258673.html
Sent from the Camel - Users mailing list archive at Nabble.com.