Adam Greene
unread,Nov 10, 2009, 7:35:32 PM11/10/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to AMQP
hey everyone,
I have a script that at the end pushes a msg to the queue and then
exits (no exit called, it just hits the end of the script). I noticed
that the msg wasn't ending up on a queue unless I added a sleep(2) at
the very bottom of the script, and then it was added. removing the
sleep(2) causes the msg to be dropped.
specifically I'm using rails, and this script is part of db/seeds.rb,
and triggered by 'rake db:setup'. The very last thing it does is try
to put a msg onto an existing queue. However, it only will do so if I
add a sleep(2) at the bottom of seeds.rb. If there is no sleep before
it exists, the msg is not put on the queue.
I suspect that the msg is somewhere in EM which is exiting before the
msg can be written.
AMQP is running in its own thread, via:
Thread.new { AMQP.start(start_configs) }
and the following traps are defined:
Signal.trap('INT') { AMQP.stop{ EM.stop } }
Signal.trap('TERM'){ AMQP.stop{ EM.stop } }
but no luck.
Of course, I can just keep the sleep(2) at the end of seeds.rb, but I
would like to make sure that for any shutdown (end of script, signal
to restart the server, cron jobs, whatever) AMQP has had a chance to
push all msgs to RabbitMQ before shutting down. Any thoughts or
ideas?
thanks for your help with what I'm sure is kind of a noob question.
Adam