camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elena <el...@hotmail.com>
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:

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

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"
xmlns="http://camel.apache.org/schema/spring">
		<camel:contextScan />
		<camel:jmxAgent id="agent" createConnector="false" />
		<camel:template id="camelTemplate" />
	</camel:camelContext>

We will appreciate your recommendations.

Thanks,
Elena



--
View this message in context: http://camel.465427.n5.nabble.com/ProducerTemplate-creates-too-much-threads-tp5751299p5751367.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message