camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Injecting ProducerTemplates, scoping, and JMX memleak
Date Tue, 13 Apr 2010 07:15:42 GMT
On Tue, Apr 13, 2010 at 1:22 AM, matthewm <mmoaot@gmail.com> wrote:
>
> Hello,
>
> We are using Camel 2.2.0 with Spring 3.0.1.RELEASE in the context of a web
> service.
>
> We've been using @EndpointInject to inject ProducerTemplates into our beans.
> Some of our beans are request scoped, and so a new ProducerTemplate is
> created and injected on each request.
>
> After more study this seems to run counter to the idea of ProducerTemplate,
> which appears to have been conceived as a long-lived object rather than
> transient.  It seems perhaps the documentation of @EndpointInject might
> point this out; injecting into singletons makes perfect sense but injecting
> into request-scoped beans may be undesirable.
>

The FAQ has some details on producer template
http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html

You can just use @Autowired or other Spring IoC stuff.

@Autowired
private ProducerTemplate template;

Camel will automatic enlist a ProducerTemplate if you do not explict
set a <template id="xxx"/> in the <camelContext/> tag.
Then it will use the shared instance of ProducerTemplate instead of
creating a new one each time.


> Specifically, the issue we found is that each ProducerTemplate creates a
> Producer which then is registered with JMX.  Eventually we wind up with
> thousands of Producers referenced by JMX (but otherwise garbage) resulting
> in OOM errors.
>

Yeah this is fixed in 2.3-SNAPSHOT.

> It seems like a bug that Camel's JMX integration prevents producers from
> being eligible for GC.  But how best to proceed with making a
> ProducerTemplate available to request scoped beans?
>
> Thanks!
>
> Matt
> --
> View this message in context: http://old.nabble.com/Injecting-ProducerTemplates%2C-scoping%2C-and-JMX-memleak-tp28219199p28219199.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message