<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&nbsp;</font><span class="Apple-style-span" style="font-family: Courier; ">either&nbsp;</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. &nbsp;The tag identifies the consumer. &nbsp;To stop&nbsp;</font></div><div><font class="Apple-style-span" face="Courier">consuming you issue&nbsp;</font><span class="Apple-style-span" style="font-family: Courier; ">basicCancel(tag) on the same channel. &nbsp;</span></div><div><span class="Apple-style-span" style="font-family: Courier; ">This stops just this&nbsp;</span><font class="Apple-style-span" face="Courier">one Consumer. It&nbsp;</font><span class="Apple-style-span" style="font-family: Courier; ">can be issued from&nbsp;</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&nbsp;</span><span class="Apple-style-span" style="font-family: Courier; ">will be called once before it stops:&nbsp;</span></div><div><span class="Apple-style-span" style="font-family: Courier; ">handleCancelOk() is&nbsp;</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 &gt;client&lt; from consuming; in</font></div><div><font class="Apple-style-span" face="Courier">general there is no general and reliable Java way of stopping&nbsp;</font></div><div><font class="Apple-style-span" face="Courier">a thread,&nbsp;</font><font class="Apple-style-span" face="Courier">and a&nbsp;</font><span class="Apple-style-span" style="font-family: Courier; ">client may in any case have several threads&nbsp;</span></div><div><span class="Apple-style-span" style="font-family: Courier; ">running.&nbsp;</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&nbsp;</span><span class="Apple-style-span" style="font-family: Courier; ">supply more details&nbsp;</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 &nbsp;<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>&nbsp;</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; ">&nbsp;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>&nbsp;<i>n.</i>&nbsp;The next bottle-size up from a&nbsp;</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>&nbsp;</span></font><font class="Apple-style-span" face="Georgia" size="2"><span class="Apple-style-span" style="font-size: 10px; "><i>adv.</i>&nbsp;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> &nbsp;&nbsp;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 &lt;0x22ce4fd8&gt; (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 &lt;0x22ce4fd8&gt; (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>