【问题标题】:Bunny::AccessRefused message when trying to read messagesBunny::AccessRefused 消息在尝试阅读消息时
【发布时间】: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)

【问题讨论】:

    标签: ruby rabbitmq amqp bunny


    【解决方案1】:

    在我见过的大多数 RMQ 配置中,消费者将有权创建他们需要的队列。

    如果您必须设置您的权限,以便您无法从您的消费者创建队列,我建议您使用opening an issue ticket with the Bunny gem。貌似不支持

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-13
      • 2013-03-07
      • 2012-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多