mikemadisonweb / yii2-rabbitmq

RabbitMQ Extension for Yii2
MIT License
72 stars 32 forks source link

setupFabric is creating a useless queue for every Producer #19

Closed michaelarnauts closed 7 years ago

michaelarnauts commented 7 years ago

The default setup of a producer is creating a queue. This is a strange behavior. You specifically need to set 'declare' => false to stop this.

I guess this should be default behavior to not create a queue when it's not specified. Every time a worker is restarted, the autoSetupFabric makes sure setupFabric is run again, and a new queue is created resulting in tons of queues.

    'producers' => [
        'server' => [
            'connection' => 'conn',
            'exchange_options' => [
                'name' => 'exchange',
                'type' => 'topic',
            ],
            'queue_options' => [
                'declare' => false,
            ]
        ],
    ],
...
mikemadisonweb commented 7 years ago

Hi, Michael These defaults are taken from php-amqplib library, which is an official package for RabbitMQ in PHP. I think they have their reasons to do that. Moreover, if somebody is used to deal with this package already, I think this person would expect defaults to be that way.