Quote from the link you gave:
You do not have to create a ProducerTemplate for every call to the message; You must create one instance at startup and save it.
Also, when you are finished using ProducerTemplate, you must call the stop () method to close all the resources that it used.
So, in a typical web application, you do not create a ProducerTemplate
for each request, for example:
ProducerTemplate template = camelContext.createProducerTemplate();
This is considered bad practice, for obvious reasons.
Instead, an endpoint should be entered, for example. using @EndpointInject
annotation
@EndpointInject(uri = "file:{{file.inbox}}") private ProducerTemplate inbox;
as described here .
source share