<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 30, 2010, at 12:43 PM, Matthew Sackman wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi Jon,<br><br>On Mon, Aug 30, 2010 at 08:28:33AM -0500, Jon Brisbin wrote:<br><blockquote type="cite">In my webhooks plugin, I'm trying to add some basic support for scheduling requests to go out at a particular time. Rather than try to implement some kind of sleep() call that waits until the next configured send window (which is getting a little complicated to manage) I'd like to simply cancel the consumer whenever the time is after a send window and start it back up whenever the window opens. I can figure out whether I'm in a send window easy enough but when I try to turn the consumer on and off (by asynchronously doing basic.cancel and basic.consume) it will give me an error something along the lines of (my logs have rolled past this error long ago, sorry for not having it verbatim) "unexpected delivery and no default consumer". I think this is coming from the erlang client, not the broker. <br></blockquote><br>Hmm, that error was meant to catch the case where you do a basic.cancel,<br>but you have outstanding unack'd messages and then you do<br>basic.redeliver - the messages get resend but the client has since lost<br>knowledge about that ctag, hence the error.<br></div></blockquote><div><br></div><div>I probably do have unack'd messages waiting because I'm trying to limit the number of messages coming through. But I wasn't doing a redeliver, though...</div><br><blockquote type="cite"><div><br>If you're doing a basic.cancel with nowait = true then I can certainly<br>believe this would happen then too. But why are you doing that?<br><br><blockquote type="cite">Is there a way to "nicely" manage the consumer so that it stops reasonably (not by simply interrupting whatever it's currently doing)? A kind of "cancel this consumer after the next message delivery"? Or should I be doing this in a different way?<br></blockquote><br>Yes - any of:<br>1. don't use the nowait version of basic.cancel<br>2. set qos prefetch_count to 1 and never cancel unless you have an<br>unacknowledged message<br>3. use amqp_channel:register_default_consumer to set a consumer which<br>will be invoked if the ctag isn't recognised.<br><br>Matthew<br></div></blockquote></div><div><br></div>Hmmm. I was using the defaults:<div><br></div><div>amqp_channel.call(Channel, #'basic.cancel'{ consumer_tag=Tag }),</div><div><br></div><div>I probably want to do #3 as well, no matter what. I don't really *care* if a message sneaks through after a window is closed. I don't have to be that accurate. I just need it to stop any new messages from being processed until I start the consumer again when another send window has opened. </div><div><br></div><div><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Palatino; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; 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-family: Times; font-size: 14px; 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-family: Helvetica; font-size: 12px; 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" face="Palatino" size="4"><span class="Apple-style-span" style="font-size: 14px; "><br class="Apple-interchange-newline">Thanks!</span></font></div><div><font class="Apple-style-span" face="Palatino" size="4"><span class="Apple-style-span" style="font-size: 14px; "><br></span></font></div><div><font class="Apple-style-span" face="Palatino" size="4"><span class="Apple-style-span" style="font-size: 14px; ">J. Brisbin</span></font></div><div><font class="Apple-style-span" face="Palatino" size="4"><span class="Apple-style-span" style="font-size: 14px; "><a href="http://jbrisbin.com/">http://jbrisbin.com/</a></span></font></div><div><font class="Apple-style-span" face="Palatino" size="4"><span class="Apple-style-span" style="font-size: 14px; "><br></span></font></div><div><font class="Apple-style-span" face="Palatino" size="4"><span class="Apple-style-span" style="font-size: 14px; "><br></span></font></div></div><font class="Apple-style-span" face="Palatino" size="4"><span class="Apple-style-span" style="font-size: 14px; "><br></span></font></div></span><br class="Apple-interchange-newline"></span><br class="Apple-interchange-newline"></span>
</div>
<br></div></body></html>