Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to ensure that a single message is published? #19

Open
TrevorBurnham opened this issue Jul 28, 2010 · 1 comment
Open

How to ensure that a single message is published? #19

TrevorBurnham opened this issue Jul 28, 2010 · 1 comment

Comments

@TrevorBurnham
Copy link

Try running the following Ruby file:

require 'rubygems'
require 'mq'

EM.run {
  amq = MQ.new
  queue = amq.queue("whatev")
  queue.publish({"foo" => "bar"})
  break
}

The message is never published. If you remove the break, then it is. What should I be doing here to ensure that the message is sent, and then leave the EventMachine loop when it is?

@botanicus
Copy link
Collaborator

Try:

EM.run {
  amq = MQ.new
  queue = amq.queue("whatev")
  amq.callback {
    puts "Callback fired!"
    break # It'll cause LocalJumpError, but otherwise it does what you want.
  }
  queue.publish({"foo" => "bar"})
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants