<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><font class="Apple-style-span" face="Courier">I cannot tell from where you wish to stop the client.</font><div><font class="Apple-style-span" face="Courier">I will assume you mean from another Java thread.<br></font></div><div><font class="Apple-style-span" face="Courier"><br></font></div><div><font class="Apple-style-span" face="Courier">To start consuming, you issued basicConsume(...) and </font><span class="Apple-style-span" style="font-family: Courier; ">either </span></div><div><span class="Apple-style-span" style="font-family: Courier; ">supplied a tag (java.lang.String) to or had one returned</span></div><div><font class="Apple-style-span" face="Courier">from this call. The tag identifies the consumer. To stop </font></div><div><font class="Apple-style-span" face="Courier">consuming you issue </font><span class="Apple-style-span" style="font-family: Courier; ">basicCancel(tag) on the same channel. </span></div><div><span class="Apple-style-span" style="font-family: Courier; ">This stops just this </span><font class="Apple-style-span" face="Courier">one Consumer. It </font><span class="Apple-style-span" style="font-family: Courier; ">can be issued from </span></div><div><span class="Apple-style-span" style="font-family: Courier; ">another thread.</span></div><div><span class="Apple-style-span" style="font-family: Courier; "><br></span></div><div><span class="Apple-style-span" style="font-family: Courier; ">The Consumer </span><span class="Apple-style-span" style="font-family: Courier; ">will be called once before it stops: </span></div><div><span class="Apple-style-span" style="font-family: Courier; ">handleCancelOk() is </span><span class="Apple-style-span" style="font-family: Courier; ">the last callback it receives.</span></div><div><font class="Apple-style-span" face="Courier"><br></font></div><div><font class="Apple-style-span" face="Courier">But you asked about stopping a >client< from consuming; in</font></div><div><font class="Apple-style-span" face="Courier">general there is no general and reliable Java way of stopping </font></div><div><font class="Apple-style-span" face="Courier">a thread, </font><font class="Apple-style-span" face="Courier">and a </font><span class="Apple-style-span" style="font-family: Courier; ">client may in any case have several threads </span></div><div><span class="Apple-style-span" style="font-family: Courier; ">running. </span><span class="Apple-style-span" style="font-family: Courier; ">To stop a whole client from consuming would require</span></div><div><span class="Apple-style-span" style="font-family: Courier; ">application specific code.</span></div><div><span class="Apple-style-span" style="font-family: Courier; "><br></span></div><div><span class="Apple-style-span" style="font-family: Courier; ">Of course closing the channel will stop all the consumers</span></div><div><span class="Apple-style-span" style="font-family: Courier; ">but I guess you want something less draconian.</span></div><div><span class="Apple-style-span" style="font-family: Courier; "><br></span></div><div><span class="Apple-style-span" style="font-family: Courier; ">I hope this helps you. If not, please </span><span class="Apple-style-span" style="font-family: Courier; ">supply more details </span></div><div><span class="Apple-style-span" style="font-family: Courier; ">of your application and requirement</span><span class="Apple-style-span" style="font-family: Courier; ">.</span></div><div><div><br class="webkit-block-placeholder"></div><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><font class="Apple-style-span" size="3">Steve Powell <span class="Apple-style-span" style="font-family: Georgia; font-size: 11px; ">(<i>a happy bunny</i>)</span></font></div></div><div style="font-family: Georgia; font-size: medium; "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 11px; "><div style="font-family: Helvetica; font-size: 12px; "><i><font class="Apple-style-span" face="Georgia" size="2"><span class="Apple-style-span" style="font-size: 10px; ">----------some definitions from the SPD----------</span></font></i></div><div style="font-family: Helvetica; font-size: 12px; "><font class="Apple-style-span" face="Georgia" size="2"><span class="Apple-style-span" style="font-size: 10px; "><b>Rigatoni</b> </span><font class="Apple-style-span" size="2"><span class="Apple-style-span" style="font-size: 10px; "><i>n.</i></span></font><span class="Apple-style-span" style="font-size: 10px; "> A prime-ministerial grin.</span></font></div><div style="font-family: Helvetica; font-size: 12px; "><font class="Apple-style-span" face="Georgia" size="2"><span class="Apple-style-span" style="font-size: 10px; "><b>Nigella</b> <i>n.</i> The next bottle-size up from a </span></font><span class="Apple-style-span" style="line-height: 15px; "><font class="Apple-style-span" face="Georgia" size="2"><span class="Apple-style-span" style="font-size: 10px; ">Nebuchadnezzar</span></font></span><font class="Apple-style-span" face="Georgia" size="2"><span class="Apple-style-span" style="font-size: 10px; ">.</span></font></div><div style="font-family: Helvetica; font-size: 12px; "><font class="Apple-style-span" face="Georgia" size="2"><span class="Apple-style-span" style="font-size: 10px; "><b>Homily</b> </span></font><font class="Apple-style-span" face="Georgia" size="2"><span class="Apple-style-span" style="font-size: 10px; "><i>adv.</i> Rather like a frenchman.</span></font></div></span></font></div></div></span></div></span></div></span></span></span>
</div>
<br><div><div>On 20 Oct 2011, at 07:52, dusura wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi,<br><br>I would like to tell a Java Client to stop consuming. The client is<br>running in a separate thread. How can I do this?<br><br>I tried interrupting the thread but the RabbitMQ impl swallows<br>InterruptedException.<br><br>Any suggestions would be appreciated.<br><br>Cheers.<br><br>My thread looks like this:<br><br>"Thread-1" prio=6 tid=0x03766400 nid=0x738 in Object.wait()<br>[0x03f0f000]<br> java.lang.Thread.State: WAITING (on object monitor)<br><span class="Apple-tab-span" style="white-space:pre">        </span>at java.lang.Object.wait(Native Method)<br><span class="Apple-tab-span" style="white-space:pre">        </span>at java.lang.Object.wait(Object.java:485)<br><span class="Apple-tab-span" style="white-space:pre">        </span>at com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:50)<br><span class="Apple-tab-span" style="white-space:pre">        </span>- locked <0x22ce4fd8> (a<br>com.rabbitmq.utility.BlockingValueOrException)<br><span class="Apple-tab-span" style="white-space:pre">        </span>at<br>com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:<br>89)<br><span class="Apple-tab-span" style="white-space:pre">        </span>- locked <0x22ce4fd8> (a<br>com.rabbitmq.utility.BlockingValueOrException)<br><span class="Apple-tab-span" style="white-space:pre">        </span>at<br>com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:<br>33)<br><span class="Apple-tab-span" style="white-space:pre">        </span>at com.rabbitmq.client.impl.AMQChannel<br>$BlockingRpcContinuation.getReply(AMQChannel.java:337)<br><span class="Apple-tab-span" style="white-space:pre">        </span>at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:<br>210)<br><span class="Apple-tab-span" style="white-space:pre">        </span>at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:<br>128)<br><span class="Apple-tab-span" style="white-space:pre">        </span>at com.rabbitmq.client.impl.ChannelN.basicGet(ChannelN.java:808)<br><span class="Apple-tab-span" style="white-space:pre">        </span>at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)<br><span class="Apple-tab-span" style="white-space:pre">        </span>at<br>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:<br>25)<br><span class="Apple-tab-span" style="white-space:pre">        </span>at java.lang.reflect.Method.invoke(Method.java:597)<br>..............<br><br>_______________________________________________<br>rabbitmq-discuss mailing list<br><a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss<br></div></blockquote></div><br></div></body></html>