camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Johnson <brad.john...@mediadriver.com>
Subject Re: Should i start/stop producer templates often
Date Fri, 09 Sep 2016 16:28:26 GMT
I'm not sure this is the problem but you don't need to create a singleton
for the ProducerTemplate.  You won't end up spinning one up for ever
request. Is there a syncrhonized anywhere on the singleton that accesses
the ProducerTemplate you are creating?

Brad

On Thu, Sep 8, 2016 at 10:49 PM, niteshjain <niteshjain132@gmail.com> wrote:

> Im using Camel 2.16.0 and cxf 3.1.2
>
> I see that alot of threads are in Waiting state on ProducerTemplate.
>
> I have created a singleton class which will create the template only
> once(during startup).
> My application server runs forever,
> Camel suggests that we have to call stop() to release the resources held,
> so
> I'm calling template.start() for each http requests and then calling
> template.stop() to release the resources held, and the same repeats for
> subsequent requests.. is this right way of using ?
> http://camel.apache.org/why-does-camel-use-too-many-
> threads-with-producertemplate.html
>
> //for each requests do this.
> ProducerTemplate template = ContextAware.getProducerTemplate(); //template
> is created oly once
> template.start();
> Object response = template.requestBody("direct:invokeWS", payload);
> template.stop(); //release the resources held
>
> I also see that, ProducerTemplate has a cached pool to hold the reference
> of
> these producer, the default size of pool is 1000, which means you can see
> lots of threads waiting there.
> references :
> http://camel.465427.n5.nabble.com/ProducerTemplate-creates-
> too-much-threads-td5751299.html
>
> Please suggest, how to use producer template for multiple requests when my
> application runs forever, and how to configure the pool for the same
>
> Regards,
> Nithesh
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/Should-i-start-stop-producer-templates-often-tp5787400.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message