Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to configure consumer for multiple queues with priority? #11425

Closed
dimanzver opened this issue Jun 10, 2024 · 1 comment
Closed

Comments

@dimanzver
Copy link

Is your feature request related to a problem? Please describe.

Is it possible to set up so that the consumer receives messages first from the first queue, then from the second, then from the third? That is, so that messages in different queues have different priorities. As soon as the tasks in the first queue run out, we consume messages from second queue, when the tasks in it run out, we consume messages from third queue. If at this time a message suddenly appears in the first queue, then we process it. Yes, I know that there are message priorities, but we have plans to use queues with the "quorum" type that do not support message priorities.

Describe the solution you'd like

I tried this, but not works correctly (consumer receives 1 message from queue p1, then 1 message from queue p2, then 1 message from queue p1, then 1 message from queue p2, etc...):

$connection = new AMQPConnection(compact('host', 'port', 'login', 'password'));
$connection->connect();

$channel = new AMQPChannel($connection);
$channel->qos(0, 1);

$queue = new AMQPQueue($channel);
$queue->setName('p1');
$queue->consume();

$queue = new AMQPQueue($channel);
$queue->setName('p2');

$queue->consume(function (\AMQPEnvelope $extEnvelope, \AMQPQueue $q) use ($connection) {
    var_dump($extEnvelope->getBody());
    sleep(1);
    $q->ack($extEnvelope->getDeliveryTag());
});

Describe alternatives you've considered

No response

Additional context

No response

@michaelklishin
Copy link
Member

@dimanzver your question was moved to #11422 and answered there. Our team does not use issues for questions.

@rabbitmq rabbitmq locked as resolved and limited conversation to collaborators Jun 10, 2024
@michaelklishin michaelklishin converted this issue into discussion #11426 Jun 10, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants