[rabbitmq-discuss] RabbitMQ RPC in Tomcat container

steven.willems at i-develop.be steven.willems at i-develop.be
Fri Jul 26 00:30:51 BST 2013

Managed to get it working:

* passed in my own ExecutorService when creating the connection and stored 
it in the ServletContextListener
* Used Executors.newCachedThreadPool(); -> not necessary, but is good as 
many short executions, and unused threads die after 60s idle time
* Shutdown threads in ServletContextListener.destroyed(). First thought 
this didn't work as my breakpoint was not reached, but somehow, breakpoint 
just seem not to work there (could make sense when I think about it, I'm 
stopping the process so debugger might already be detached). But logging 
assures me now my code is executed.
ServletContextListener.destroyed() {
            executorService.awaitTermination(20, TimeUnit.SECONDS);

And that's it :)

Op woensdag 24 juli 2013 17:08:32 UTC+2 schreef steven.... at i-develop.be het 
> I'm trying to setup RabbitMQ RPC in a web project (like suggested in tutorial 
> 6 <http://www.rabbitmq.com/tutorials/tutorial-six-java.html>). It works 
> as intended, but when I try to shutdown Tomcat, the shutdown hangs as soon 
> as I have created a consumer listening to the rpc response. 
> jstack and some debugging learned me that for each created consumer, a 
> thread is created. And those threads are preventing Tomcat from shutting 
> down (as they are not managed by Tomcat).
> Looking at ConsumerWorkService, there is a method addWork, which creates 
> a new WorkPoolRunnable and if I have understood it correctly, those 
> Runnable's are only stopped when the 'key', being the channel is stopped.
> I find that a bit odd.. I would expect that when I call stub.channel.basicCancel(consumer.getConsumerTag()); 
> the runnable for the consumer is removed. 
> Or am I completely wrong about my findings and is something else going on?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130725/dd653d30/attachment-0001.htm>

More information about the rabbitmq-discuss mailing list