[rabbitmq-discuss] Turning consumers on/off in Erlang client
jon at jbrisbin.com
Mon Aug 30 14:28:33 BST 2010
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.
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?
I've got my consume and cancel calls in a handle_info() which I trigger with the usual "self() ! cancel" etc... from the code that checks whether or not I'm within a send window.
The problem is a little more complicated than I thought in that I can configure multiple windows and I have to figure out which one is closer to the present time (including wrapping around midnight into the next morning). Though the code to manage this is a little more unwieldy than I'd like, it's really only the consumer cancel/consume calls that are giving me fits. Everything else seems to work okay. Arg! :/
Can anyone point me in the right direction on troubleshooting this?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rabbitmq-discuss