DOCS:report incident tutorial has leaky code. (recreates producerTemplate())
-----------------------------------------------------------------------------
Key: CAMEL-2818
URL: https://issues.apache.org/activemq/browse/CAMEL-2818
Project: Apache Camel
Issue Type: Improvement
Components: documentation, examples, website
Environment: Tomcat 6.0.26
Reporter: Karl Palsson
Priority: Trivial
On http://camel.apache.org/tutorial-example-reportincident-part4.html in the
section labelled: {{Adding the RouteBuilder}}, there is some code labelled as
being inside the web service operation...
{code:java}
public OutputReportIncident reportIncident(InputReportIncident parameters) {
Object mailBody =
context.createProducerTemplate().sendBody("direct:start", parameters);
System.out.println("Body:" + mailBody);
// return an OK reply
OutputReportIncident out = new OutputReportIncident();
out.setCode("OK");
return out;
}
{code}
The commentary underneath makes special note of obtaining the producerTemplate
with {{context.createProducerTemplate()}}
However, using this example code will result in leaks of DirectProducer objects
(under camel 2.1.x) or ThreadPoolExecutors (under camel 2.3.x) and eventual
heap exhaustion.
A web service implementation class should create a single producer template,
and reuse it. Alternatively, there's something wild and wooly going on that's
preventing the template from being garbage collected.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.