bschmitt / laravel-amqp

AMQP wrapper for Laravel and Lumen to publish and consume messages
MIT License
268 stars 86 forks source link

Cant get shrading to work #67

Open vpaskovic opened 5 years ago

vpaskovic commented 5 years ago

I am having issue using sharding. I want to achieve having one queue that has 6 consumers but with sharding to achieve that each consumer is on one CPU.

After enabling rabbitmq-plugins enable rabbitmq_sharding

and setting up config

'exchange'              => 'shard.videos',
'exchange_type'         => 'x-modulus-hash',

making policy rabbitmqctl set_policy videos-shard "^shard.videos$" "{""shards-per-node"": 1,""routing-key"": ""fc_analyze""}"

with \Amqp::publish('fc_analyze', 'this is message');

I get it to wright queue but can not get consumer in that queue using this code

\Amqp::consume('videos', function ($message, $resolver) {
         var_dump($message->body);
         sleep(20);
         $resolver->acknowledge($message);
      }, [
        'message_limit' => 1,
        'exchange' => 'shard.videos',
        'exchange_type' => 'x-modulus-hash',
        'routing_key' => 'fc-analyze',
     ]
);

Please help and advice. Thank you

stevenklar commented 4 years ago

@vpaskovic The queue name is 'shard.videos' right? But you got 'videos' and 'shard.videos' mixed.

Just reopen this issue if it's still not working.

vpaskovic commented 4 years ago

Hi @stevenklar when I put 'shard.videos' in \Amqp::consume('shard.videos', there is Error, as it does not accept queue name with dots. So there is still a problem.

stevenklar commented 4 years ago

Right now I'm not sure if we support this. Must be tested.

/Reopen