Thomas Küstermann created CAMEL-16006:
-----------------------------------------

             Summary: Improve ProducerTemplate documentation and code examples 
using ProducerTemplate
                 Key: CAMEL-16006
                 URL: https://issues.apache.org/jira/browse/CAMEL-16006
             Project: Camel
          Issue Type: Improvement
          Components: documentation
    Affects Versions: 3.7.0
            Reporter: Thomas Küstermann


I'm currently reading about error handling in Camel, specifically [Using a 
Processor as a failure 
handler|https://camel.apache.org/manual/latest/exception-clause.html#ExceptionClause-UsingaProcessorasaFailureHandler].

The code example lists

{code:java|title=Code Example}
// send it to our mock endpoint
exchange.getContext().createProducerTemplate().send("mock:myerror", exchange);
{code}

According to the Javadoc of {{createProducerTemplate()}} and 
{{ProducerTemplate}} this is problematic:

* {{stop()}} must be called when the {{ProducerTemplate}} is not further needed
* Recommended practice is to use just one {{ProducerTemplate}} in the 
application
* [Why does Camel use too many threads with 
ProducerTemplate?|https://camel.apache.org/manual/latest/faq/why-does-camel-use-too-many-threads-with-producertemplate.html]

Since we're all lazy devs, we tend to copy paste code listings and think we're 
done.

I suggest the following:

* Add a section _Recommended Practice_ to [user manual 
ProducerTemplate|https://camel.apache.org/manual/latest/producertemplate.html] 
which basically lists the important bits of FAQ article [Why does Camel use too 
many threads with 
ProducerTemplate?|https://camel.apache.org/manual/latest/faq/why-does-camel-use-too-many-threads-with-producertemplate.html]
* Fix code example in [Using a Processor as a failure 
handler|https://camel.apache.org/manual/latest/exception-clause.html#ExceptionClause-UsingaProcessorasaFailureHandler].
* Maybe scan through other code samples?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to