camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elena <>
Subject Re: ProducerTemplate creates too much threads
Date Tue, 20 May 2014 18:00:16 GMT
Hi Claus,

Thank you for the response.

Our server is multithreaded web-application. It sends requests to the
multiple endpoints in separate threads.

Please see below the sample of the code.

private ProducerTemplate camelTemplate;

synchronized public List<HubRequest> executeMultipleQueries(final String[]
hubUIDs, final QueryParameter[] params) {
	for (String hubId : hubUIDs) {
		Runnable task = new Runnable() {
            public void run() {
				try {
					Object resp = camelTemplate.requestBodyAndHeader(requestUri, params,
"responseUri", responseUri);
				} catch () {

What should we do in this case to release the ProducerTemplate resources?

a) Start the service every time before the request and stop after the
response have been received, for example:

Object resp = camelTemplate.requestBodyAndHeader(requestUri, params,
"responseUri", responseUri);

b) Or use multiple ProducerTemplates? 

What will be the best solution? Our server processes a lot of requests sent
from the client application.
Currently we use only one ProducerTemplate defined in the camelContext:

	<camel:camelContext id="ent-camel-client"
		<camel:contextScan />
		<camel:jmxAgent id="agent" createConnector="false" />
		<camel:template id="camelTemplate" />

We will appreciate your recommendations.


View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message