【发布时间】:2015-11-12 15:31:58
【问题描述】:
我正在尝试使用 Bunny 从队列中读取消息。我在 RabbitMQ 服务器上只有读取权限,但似乎我正在使用的代码尝试创建队列 - 尽管我可以看到队列已经存在 queue_exists?()。
Bunny 中一定有一个进程可以简单地从现有队列中读取消息吗?这是我正在使用的代码
require 'bunny'
class ExampleConsumer < Bunny::Consumer
def cancelled?
@cancelled
end
def handle_cancellation(_)
@cancelled = true
end
end
conn = Bunny.new("amqp://xxx:xxx@xxx", automatic_recovery: false)
conn.start
ch = conn.channel
q = ch.queue("a_queue")
consumer = ExampleConsumer.new(ch, q)
当我执行上述操作时,我收到:
/Users/jamessmith/.rvm/gems/ruby-1.9.3-p392/gems/bunny-1.7.1/lib/bunny/channel.rb:1915:in `raise_if_continuation_resulted_in_a_channel_error!': ACCESS_REFUSED - access to queue 'a_queue' in vhost '/' refused for user 'xxx' (Bunny::AccessRefused)
【问题讨论】: