<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 02/04/2014 6:23 PM, Gary Russell wrote:<br>
<blockquote
cite="mid:CADtU9_vsLWqzC=rwm6WFP-2hiKf80wmVmSp5soPehQk5gu2tDQ@mail.gmail.com"
type="cite">
<div dir="ltr">In Spring-AMQP, we don't asynchronously cancel the
consumer, we tell the consumer it needs to cancel itself when
it's finished its current work. IIRC, if the consumer is running
when you cancel it, its basicAck will fail because you've
already cancelled it and the broker has re-queued that message.
Effectively we tell the consumer to emit the cancel immediately
after the ack.</div>
</blockquote>
I tested this on RabbitMQ 3.2.4 and calling basicCancel for a
consumer tag does not interfere with the ability to basicAck a
message currently being processed (I used Thread.sleep() in the
consumer to ensure the operation order). The handleCancelOk() method
is only called after the handleDelivery() method returns.<br>
<br>
From what I could piece together, calling basicCancel queues the
channel rpc command for execution after whatever is already queued.
The consumer even consumes its buffered messages (basicQos > 1)
before processing the cancel command.<br>
<br>
<blockquote
cite="mid:CADtU9_vsLWqzC=rwm6WFP-2hiKf80wmVmSp5soPehQk5gu2tDQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>><span
style="font-family:arial,sans-serif;font-size:13px">stop a
badly behaving Consumer</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px">It
depends on how badly behaved it is; if it never executes any
interruptible code (say it's stuck in a while() loop), you
are out of luck. If it does stuff that's interruptible
(acquire locks, etc, etc) then you can interrupt it.</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px">I
don't know enough about the rabbit client internals as to
whether there is a mechanism to force it to interrupt the
dispatcher thread (I didn't see anything after a quick look)
so you might have to roll your own (capture a reference to
the thread in handleDelivery and interrupt it after your
timeout).</span></div>
<div><br>
</div>
<div>When all else fails, System.exit() is your friend.</div>
</div>
</blockquote>
Yeah I think System.exit() will do the trick here. Your idea of
using my own executor and shutting it down (your other email) is
very good however, but I think I'm overengineering this a bit for my
current needs.<br>
<br>
Thanks for all your help,<br>
Bertrand<br>
</body>
</html>