Hi,
ProducerTemplates has a cache which holds the reference of the endpoints
those he send to. It's a good idea to inject a new ProducerTemplate
per request. We need to update the document for it.
The JMX issue should be fixed also, please feel free to log a JIRA[1]
for it.
[1]https://issues.apache.org/activemq/browse/CAMEL
Willem
matthewm 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.
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.
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