LoginSignup
0
0

More than 5 years have passed since last update.

ruby amqp で basic_ack を制御する

Posted at

subscribe に :ack => true を指定する必要がある。デフォルトは false で、勝手に ack を返す。

require 'amqp'

EventMachine.run do
  connection = AMQP.connect(:host => 'example.jp')

  channel = AMQP::Channel.new(connection)
  q = channel.queue("test")

  q.subscribe(:ack => true) do |hdr, payload|
    puts "Received a message: #{payload}"
    email.callback do
      puts 'email sent'
    end
    email.errback do |e|
      puts 'email failed'
    end
  end
end
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0