我正在尝试使用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)发布于 2015-11-13 00:51:00
在我见过的大多数RMQ配置中,使用者将拥有创建所需队列的权限。
如果您必须设置权限,以便不能从使用者创建队列,我建议使用opening an issue ticket with the Bunny gem。它看起来不受支持
https://stackoverflow.com/questions/33675189
复制相似问题