You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Shylendran C <sh...@gmail.com> on 2015/10/20 05:37:24 UTC

org.apache.camel.ProducerTemplate in a Multi-thread code - Breaking, need help...

I have a multi-threaded application where I have to send message
continuously and I am using org.apache.camel.ProducerTemplate. But since it
is a multi-threaded, it is breaking and getting the below exceptions. So,
I've tried with 'static synchronized' where everything is working, but we
can't go with 'static synchronized'. So looking for a solution.
It is clear that the exception is happaning when we have
ProducerTemplate.start() and stop() when multi-threads are invoking this.
We have created only one instance of ProducerTemplate.
I am using camel-code-2.15.2.jar for the development.

Is there a way which I can check whether the producer template is already
'open' or 'stop'. I see few protected variables, and while debugging I see
exactly what I am looking.
Is there any option/way that I can check whether it is already open or not.
If it is not open i can call the open(). Please let me know ASAP


org.apache.camel.CamelExecutionException: Exception occurred during
execution on the exchange: Exchange[Message: ]
Exception: Exception occurred during execution on the exchange:
Exchange[Message: ] ref#:1445293682127
at
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1635)
at
org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:645)
at
org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:471)
at
org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:467)
at
org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:245)
at
org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeaders(DefaultProducerTemplate.java:229)
at
com.hrb.fdm.routingmanager.RMThread.doNonLeapGenericSend_RMQ(RoutingManagerLite.java:328)
at com.hrb.fdm.routingmanager.RMThread.run(RoutingManagerLite.java:287)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: com.rabbitmq.client.AlreadyClosedException: connection is
already closed due to clean connection shutdown; protocol method:
#method<connection.close>(reply-code=200, reply-text=OK, class-id=0,
method-id=0)

Thanks,
Shylendran.C