<div>&lt;dependency&gt;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;groupId&gt;com.rabbitmq&lt;/groupId&gt;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;artifactId&gt;amqp-client&lt;/artifactId&gt;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;version&gt;3.0.4&lt;/version&gt;</div><div>&lt;/dependency&gt;</div><div><br></div><div><span style="color: rgb(68, 68, 68); font-family: Verdana, sans-serif; font-size: 12px; text-align: right;">RabbitMQ 3.0.2, Erlang R16A</span><br></div><div><span style="color: rgb(68, 68, 68); font-family: Verdana, sans-serif; font-size: 12px; text-align: right;"><br></span></div><div><span style="color: rgb(68, 68, 68); font-family: Verdana, sans-serif; font-size: 12px; text-align: right;">I have a webpage that has a start button and a stop button.&nbsp;</span></div><div><span style="color: rgb(68, 68, 68); font-family: Verdana, sans-serif; font-size: 12px; text-align: right;">These to buttons should start and stop the consuming messages.</span></div><div><span style="color: rgb(68, 68, 68); font-family: Verdana, sans-serif; font-size: 12px; text-align: right;"><br></span></div><div><span style="color: rgb(68, 68, 68); font-family: Verdana, sans-serif; font-size: 12px; text-align: right;">When the user presses start button the consuming starts... when the user presses the stop button the consuming stops</span></div><div><span style="color: rgb(68, 68, 68); font-family: Verdana, sans-serif; font-size: 12px; text-align: right;">BUT.. the user cannot start the consuming again.&nbsp;</span></div><div><span style="color: rgb(68, 68, 68); font-family: Verdana, sans-serif; font-size: 12px; text-align: right;">While debugging the code, I see the method call&nbsp;</span><font color="#444444" face="Verdana, sans-serif"><span style="font-size: 12px;">channel.basicCancel hangs... and the debugger stops...&nbsp;</span></font></div><div><font color="#444444" face="Verdana, sans-serif"><span style="font-size: 12px;">When I stop the JBoss server where the application is deployd I see this exception coming in the catch when doing&nbsp;channel.basicCancel.</span></font></div><div><span style="font-size: 12px; color: rgb(68, 68, 68); font-family: Verdana, sans-serif; text-align: right;">com.rabbitmq.client.ShutdownSignalException: clean channel shutdown; reason: #method&lt;channel.close&gt;(reply-code=200, reply-text=OK, class-id=0, method-id=0)</span><br></div><div><span style="text-align: right;"><font color="#444444" face="Verdana, sans-serif"><span style="font-size: 12px;"><br></span></font></span></div><div style="text-align: start;"><span style="text-align: right;"><font color="#444444" face="Verdana, sans-serif"><span style="font-size: 12px;">And in the method&nbsp;</span></font></span><font color="#444444" face="Verdana, sans-serif"><span style="font-size: 12px;">handleDelivery I see&nbsp;ShutdownSignalException...</span></font></div><div style="text-align: start;"><span style="font-size: 12px; color: rgb(68, 68, 68); font-family: Verdana, sans-serif; text-align: right;">com.rabbitmq.client.AlreadyClosedException: clean connection shutdown; reason: Attempt to use closed channe</span><span style="text-align: right;">l</span></div><div style="text-align: start;"><span style="text-align: right;"><br></span></div><div style="text-align: start;"><span style="text-align: right;">The call to&nbsp;</span>basicCancel only hangs when consuming is going on.. if I start the consuming, but no messages are on the queue, I can stop it.. and start it again.&nbsp;</div><div style="text-align: start;"><br></div><div style="text-align: start;"><div>@Override</div><div>protected final synchronized void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>String task = req.getParameter("task");</div><div>&nbsp; &nbsp; &nbsp; &nbsp; ...</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>if (StringUtils.isNotBlank(task) &amp;&amp; task.equals("stop")) {</div><div><span class="Apple-tab-span" style="white-space: pre;">                        </span>consuming = false;</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>try {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>channel.basicCancel("MonitorConsumer");</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>} catch (Exception e) {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>e.printStackTrace();</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>} else {</div><div><span class="Apple-tab-span" style="white-space: pre;">                </span>if (connection == null || channel == null) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>createRabbitConnection();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>if (!consuming) {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>channel.basicConsume(Configuration.QUEUE_JSI_TO_DASHBOARD, false, "MonitorConsumer", this);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>consuming = true;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}</div><div><br></div><div><div>public synchronized void handleDelivery(String consumerTag, Envelope envelope, BasicProperties properties, byte[] body) throws IOException {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>...</div><div>&nbsp; &nbsp; &nbsp; &nbsp; try {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>channel.basicAck(deliveryTag, false);</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>} catch (ShutdownSignalException e) {</div><div><span class="Apple-tab-span" style="white-space: pre;">                </span>e.printStackTrace();<br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>}<br></div></div></div><div style="text-align: right;"><br></div><div style="text-align: right;"><br></div><div style="text-align: right;"><br></div><div><span style="color: rgb(68, 68, 68); font-family: Verdana, sans-serif; font-size: 12px; text-align: right;"><br></span></div><div><span style="color: rgb(68, 68, 68); font-family: Verdana, sans-serif; font-size: 12px; text-align: right;"><br></span></div><div><span style="color: rgb(68, 68, 68); font-family: Verdana, sans-serif; font-size: 12px; text-align: right;"><br></span></div>