camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Problem with ProducerTemplate on context shutdown
Date Tue, 18 Sep 2012 13:26:55 GMT
On Tue, Sep 18, 2012 at 3:12 PM, Christian Schneider
<> wrote:
> Hi all,
> we had a problem with the camel shutdown at a Talend ESB Camel example after
> updating to camel 2.10-SNAPSHOT.
> The example uses a ProducerTemplate with a camel jms producer that is
> injected using an annotation:
> @EndpointInject
> ProducerTemplate producer;
> At the end of the example main the spring context and with it the camel
> context is shut down.
> Before the update the update the main then exited normally. After the update
> it did not exit.
> I found that the ProducerTemplate created a JMSProducer which with a
> DefaultMessageListenerContainer for the replies. This was still active and
> so the main did not exit.
> When I issues a producer.close(); the main exited normally.
> So the question is: Do I need to close a ProducerTemplate myself or should
> it be closed when the camel context that created it is shut down?

Yes its always the clients responsibility to invoke the stop method
when you are done with the template.
See this FAQ:

I have polished the javadoc of the createProducerTemplate methods on
CamelContext to make this more clear.

> Christian
> ---
> Here is the full example:
> and the change that made it work again:
> --
> Christian Schneider
> Open Source Architect
> Talend Application Integration Division

Claus Ibsen
Twitter: davsclaus, fusenews
Author of Camel in Action:

View raw message