Hi,<div>Along these same lines, is it considered thread-safe to call channel.basicAck from a separate thread while the &quot;host thread&quot; for the channel is blocked on QueueingConsumer#nextDeliver?  Better yet, when is it not thread-safe to call basicAck from a separate thread?</div>
<div><br></div><div>Thanks,</div><div>Adam<br><br><div class="gmail_quote">On Thu, Oct 20, 2011 at 10:09 AM, Steve Powell <span dir="ltr">&lt;<a href="mailto:steve@rabbitmq.com">steve@rabbitmq.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><font face="Courier">I cannot tell from where you wish to stop the client.</font><div>
<font face="Courier">I will assume you mean from another Java thread.<br></font></div><div><font face="Courier"><br></font></div><div><font face="Courier">To start consuming, you issued basicConsume(...) and </font><span style="font-family:Courier">either </span></div>
<div><span style="font-family:Courier">supplied a tag (java.lang.String) to or had one returned</span></div><div><font face="Courier">from this call.  The tag identifies the consumer.  To stop </font></div><div><font face="Courier">consuming you issue </font><span style="font-family:Courier">basicCancel(tag) on the same channel.  </span></div>
<div><span style="font-family:Courier">This stops just this </span><font face="Courier">one Consumer. It </font><span style="font-family:Courier">can be issued from </span></div><div><span style="font-family:Courier">another thread.</span></div>
<div><span style="font-family:Courier"><br></span></div><div><span style="font-family:Courier">The Consumer </span><span style="font-family:Courier">will be called once before it stops: </span></div><div><span style="font-family:Courier">handleCancelOk() is </span><span style="font-family:Courier">the last callback it receives.</span></div>
<div><font face="Courier"><br></font></div><div><font face="Courier">But you asked about stopping a &gt;client&lt; from consuming; in</font></div><div><font face="Courier">general there is no general and reliable Java way of stopping </font></div>
<div><font face="Courier">a thread, </font><font face="Courier">and a </font><span style="font-family:Courier">client may in any case have several threads </span></div><div><span style="font-family:Courier">running. </span><span style="font-family:Courier">To stop a whole client from consuming would require</span></div>
<div><span style="font-family:Courier">application specific code.</span></div><div><span style="font-family:Courier"><br></span></div><div><span style="font-family:Courier">Of course closing the channel will stop all the consumers</span></div>
<div><span style="font-family:Courier">but I guess you want something less draconian.</span></div><div><span style="font-family:Courier"><br></span></div><div><span style="font-family:Courier">I hope this helps you. If not, please </span><span style="font-family:Courier">supply more details </span></div>
<div><span style="font-family:Courier">of your application and requirement</span><span style="font-family:Courier">.</span></div><div><div><br></div><font color="#888888"><div>
<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;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><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;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><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;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<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;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<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;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="word-wrap:break-word">
<div><div><font size="3">Steve Powell  <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 size="3"><span style="font-size:11px"><div style="font-family:Helvetica;font-size:12px">
<i><font face="Georgia" size="2"><span style="font-size:10px">----------some definitions from the SPD----------</span></font></i></div><div style="font-family:Helvetica;font-size:12px"><font face="Georgia" size="2"><span style="font-size:10px"><b>Rigatoni</b> </span><font size="2"><span style="font-size:10px"><i>n.</i></span></font><span style="font-size:10px"> A prime-ministerial grin.</span></font></div>
<div style="font-family:Helvetica;font-size:12px"><font face="Georgia" size="2"><span style="font-size:10px"><b>Nigella</b> <i>n.</i> The next bottle-size up from a </span></font><span style="line-height:15px"><font face="Georgia" size="2"><span style="font-size:10px">Nebuchadnezzar</span></font></span><font face="Georgia" size="2"><span style="font-size:10px">.</span></font></div>
<div style="font-family:Helvetica;font-size:12px"><font face="Georgia" size="2"><span style="font-size:10px"><b>Homily</b> </span></font><font face="Georgia" size="2"><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></font><div><div></div><div class="h5">
<br><div><div>On 20 Oct 2011, at 07:52, dusura wrote:</div><br><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>&quot;Thread-1&quot; prio=6 tid=0x03766400 nid=0x738 in Object.wait()<br>
[0x03f0f000]<br>   java.lang.Thread.State: WAITING (on object monitor)<br><span style="white-space:pre-wrap">        </span>at java.lang.Object.wait(Native Method)<br><span style="white-space:pre-wrap">        </span>at java.lang.Object.wait(Object.java:485)<br>
<span style="white-space:pre-wrap">        </span>at com.rabbitmq.utility.BlockingCell.get(BlockingCell.java:50)<br><span style="white-space:pre-wrap">        </span>- locked &lt;0x22ce4fd8&gt; (a<br>com.rabbitmq.utility.BlockingValueOrException)<br>
<span style="white-space:pre-wrap">        </span>at<br>com.rabbitmq.utility.BlockingCell.uninterruptibleGet(BlockingCell.java:<br>89)<br><span style="white-space:pre-wrap">        </span>- locked &lt;0x22ce4fd8&gt; (a<br>com.rabbitmq.utility.BlockingValueOrException)<br>
<span style="white-space:pre-wrap">        </span>at<br>com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:<br>33)<br><span style="white-space:pre-wrap">        </span>at com.rabbitmq.client.impl.AMQChannel<br>
$BlockingRpcContinuation.getReply(AMQChannel.java:337)<br><span style="white-space:pre-wrap">        </span>at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:<br>210)<br><span style="white-space:pre-wrap">        </span>at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:<br>
128)<br><span style="white-space:pre-wrap">        </span>at com.rabbitmq.client.impl.ChannelN.basicGet(ChannelN.java:808)<br><span style="white-space:pre-wrap">        </span>at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)<br>
<span style="white-space:pre-wrap">        </span>at<br>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:<br>25)<br><span style="white-space:pre-wrap">        </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" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a><br><a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</div></blockquote></div><br></div></div></div></div><br>_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
<br></blockquote></div><br></div>