【问题标题】:Consumer RabbitMQ symfony2 not work消费者 RabbitMQ symfony2 不工作
【发布时间】:2015-08-07 10:37:29
【问题描述】:

在我正在开发的 Symfony 2.7 应用程序中,我需要使用 RabbitMQ 数据。 我安装了 RabbitMQBundle 并且很好,但是当我尝试使用时出现以下错误

 [PhpAmqpLib\Exception\AMQPProtocolChannelException]
 ACCESS_REFUSED - access to exchange 'options' in vhost '/' refused for user 'user'

config.yml:

 old_sound_rabbit_mq:
    connections:
      default:
        host:     'my-url'
        port:     5672
        user:     'user'
        password: 'pass'
        vhost:    '/'
        lazy:     false
        connection_timeout: 3
        read_write_timeout: 3

        # requires php-amqplib v2.4.1+ and PHP5.4+
        keepalive: false

        # requires php-amqplib v2.4.1+
        heartbeat: 0
  consumers:
    read_node:
        connection:       default
        exchange_options: { name: 'options', type: direct}
        queue_options:    { name: 'options' }
        callback:         process_node

services.yml:

 services:
     process_node:
        class: AppBundle\Consumer\RabbitConsumer

RabbitConsumer.php

  namespace AppBundle\Consumer;

 use OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface;
 use PhpAmqpLib\Message\AMQPMessage;

 class RabbitConsumer implements ConsumerInterface{


    public function execute(AMQPMessage $msg) {
        return false;
    }

}

控制台命令:

  php ./app/console rabbitmq:consumer read_node

我制作了一个纯 php 脚本并正常工作 我希望有人可以帮助我

【问题讨论】:

  • 您收到错误“ACCESS_REFUSED - 用户 'user' 拒绝访问 vhost '/' 中的交换 'options'”,因此请尝试查看用户 'user' 无法访问的内容该虚拟主机上的选项交换

标签: php symfony rabbitmq


【解决方案1】:

如果您没有更改rabbitmq的默认用户设置,您必须将用户和密码分别更改为'guest'和'guest'。

否则,您将需要在 rabbitmq 中创建一个名为“user”的新用户并将密码设置为“pass”,以便您在上面粘贴的代码正常工作。但我建议你把它改成合理的。

更改用户:

rabbitmqctl change_password tonyg newpass

添加用户:

add_user {username} {password}`

More info on the manual page of rabbitmq

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-15
    • 2020-09-12
    • 1970-01-01
    • 2016-05-04
    • 1970-01-01
    • 2020-09-20
    • 1970-01-01
    相关资源
    最近更新 更多