Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Messenger] Add possibility to route delayed messages to the origin queue directly #36196

Copy link
Copy link
Closed
@s-code

Description

@s-code
Issue body actions

Description
RabbitMQ topic exchange very often can be used as a shared channel of communication. Applications can publish own messaged to that channel and listen on messages from other apps (some times even in different technologies and languages).
Currently it's not possible to use messenger for such purposes because of retry/delay logic - after dead letter queue expires, all its messages will be redirected to origin exchange with original routing keys. So, in case of topic exchange there is a risk of multiple republication of own or other app messages to all apps, who listen on that exchange.
To solve this problem we can use origin queue redirect instead of origin exchange.

Example

if ($originQueue === null) {
    $dlExchange = $this->exchangeOptions['name'];
    $dlRoutingKey = $routingKey ?? '';
    $dlQueueName = $this->getRoutingKeyForDelay($delay, $routingKey);
} else {
    $dlExchange = '';
    $dlRoutingKey = $originQueue;
    $dlQueueName = $this->getRoutingKeyForDelay($delay, $originQueue);
}

$queue->setName($dlQueueName);
$queue->setFlags(AMQP_DURABLE);
$queue->setArguments([
    'x-message-ttl' => $delay,
    'x-expires' => $delay + 10000,
    'x-dead-letter-exchange' => $dlExchange,
    'x-dead-letter-routing-key' => $dlRoutingKey,
]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.