RabbitMqBundle上队列优先级问题

ss2ws0br  于 8个月前  发布在  RabbitMQ
关注(0)|答案(2)|浏览(124)

我正在尝试设置一个优先队列。没有优先级,它工作得很好,但我需要优先考虑消息。
我正在使用RabbitMQBundle 1.14和rabbitmq-supervisor-bundle 3.1与RabbitMQ 3.5.7(Erlang 18.3)
下面是config.yml:

old_sound_rabbit_mq:
    connections:
        default:
            host:     '127.0.0.1'
            port:     5672
            user:     'xxx'
            password: 'xxx'
            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

            #requires php_sockets.dll
            use_socket: true # default false
    producers:
        global:
            connection:       default
            exchange_options: {name: 'global', type: direct}
            queue_options:
                name: global
    consumers:
        global:
            connection:       default
            exchange_options: {name: 'global', type: direct}
            queue_options:    {name: 'global', arguments: {'x-max-priority': ['I', 10]} }
            callback:         rabbitmq_simu_service

和发送到队列的消息:

$msg = array();
$msg['id'] = $id;
$msg['action'] = 'simu';
$additionalProperties = ['priority' => 4] ;  
$routing_key = '';
$this->container->get('old_sound_rabbit_mq.global_producer')->publish(serialize($msg), $routing_key , $additionalProperties);

发送消息时出现以下错误:
PRECONDITION_FANORTH-vhost“/”中队列“global”的不等效参数"x-max-priority“:接收到的none但current是类型为“signedint”的值“10”
我也在config.yml中试过:

queue_options:    {name: 'global', arguments: {'x-max-priority': 10} }

在这种情况下,我没有得到错误,但消息没有被消费。
有谁知道如何发送优先消息吗?

z9smfwbn

z9smfwbn1#

您收到的消息是当您尝试创建队列时发生的错误消息,但队列已经存在,并且具有不同的参数。您必须先删除队列,然后尝试运行程序。

67up9zun

67up9zun2#

PRECONDITION_FANORTH-vhost“/”中队列“global”的不等效参数"x-max-priority“:接收到的none但current是类型为“signedint”的值“10”
该消息意味着您已经创建了global队列,其最大优先级为10,但是其他东西正在尝试声明它,而没有优先级。您必须检查生产者 * 和消费者的代码,以确保它们在声明此优先级队列时使用完全相同的x-max-priority参数。

相关问题