Hi If you use dynamic request and response queues (eg use many queues instead of few) and if those queues are not to be reused, then you would need to close the resources when you are done.
So it would only make sense to reuse the producer template for queues you want to reuse in the future. And for one time usage only, then create a new template, and stop it after use. Also Camel 2.10.x is a bit old, you may try upgrading as we fix stuff in newer releases. On Tue, May 20, 2014 at 8:00 PM, elena <[email protected]> wrote: > 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. -- Claus Ibsen ----------------- Red Hat, Inc. Email: [email protected] Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
