Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Messenger] Ability to distinguish retry and delay actions#36864
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
102bf8e tof6e8c45Comparenicolas-grekas commentedMay 19, 2020
Neither would this be allowed in master since it would break apps migrating to 5.2. Can we find another idea? |
798e402 tod3124bfComparetheravel commentedMay 19, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nicolas-grekas Thank you for the feedback. I changed it: now Should I change target branch in this case? |
nicolas-grekas commentedMay 19, 2020
Yes please if this should be considered as a bugfix (I didn't check that part). |
d3124bf toaa81532Comparetheravel commentedMay 19, 2020
@nicolas-grekas changed target to 4.4 |
| } | ||
| publicstaticfunctioncreateFromAmqpEnvelope(\AMQPEnvelope$amqpEnvelope,self$previousStamp =null):self | ||
| publicfunctionisEnvelopeRedelivered():bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is really confusing. AMQP also has the concept of redelivery. But this is not the same as the redelivery in the messenger component. Since this is the stamp to encode the amqp flags, this is really unexpected. So this needs a different name or not be exposed at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This has been renamed
Tobion commentedMay 23, 2020
s-code commentedMay 28, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@theravel i was able to solve this and few other problems without changing Messenger connection class, but it's little bit tricky. Here is an examplehttps://github.com/s-code/amqp-extra-bundle. Take a look on ExtraAmqpFactory, ExtraAmqpSender, ExtraAmqpQueue, ExtraAmqpExchange. |
weaverryan commentedOct 22, 2020
On a high level, this makes sense to me: If a message is in queue A, and I read it from queue A and it fails, then it should go back onto queue A only. Messenger handles retries by actually ack'ing the original message and redelivering it. But ultimately, the desired behavior (I think) would be what I described above and what this PR does. Though, apparently this and#38486 solve the same problem (is it theexact same problem?) but in different ways.@s-code could you comment on what your PR does versus this one? Thanks :) |
s-code commentedOct 22, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@weaverryan you are right. This two pull requests solve the same problem. The difference is in next things:
|
aa81532 to5d084a2Comparenicolas-grekas commentedApr 12, 2021
(please add a changelog entry in the bridge) |
theravel commentedApr 12, 2021
@nicolas-grekas Changelog entry added |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Messenger/Bridge/Amqp/Transport/AmqpStamp.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Nyholm left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Im happy with this. Just one question
| } | ||
| publicstaticfunctioncreateFromAmqpEnvelope(\AMQPEnvelope$amqpEnvelope,self$previousStamp =null):self | ||
| publicstaticfunctioncreateFromAmqpEnvelope(\AMQPEnvelope$amqpEnvelope,self$previousStamp =null,string$retryRoutingKey =null):self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We are using$amqpReceivedStamp->getQueueName() to populate the$retryRoutingKey, is that really correct?
A routing key is not the same as the queue name.
(It is probably correct, but I just need you to clarify.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is correct. We want to distinguish:
- delay scenario, where message should be sent to original exchange to original routing key (so that all consumers can get it)
- retry scenario, where message should be sent to default (direct) exchange to routing key which matches queue name (in this case it will be received in one queue only)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Are we sure the routing key always matches the queue name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
For direct exchange in AMQP 0-9-1 yes:
The default exchange is a direct exchange with no name (empty string) pre-declared by the broker. It has one special property that makes it very useful for simple applications: every queue that is created is automatically bound to it with a routing key which is the same as the queue name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@Nyholm can you review please?
MichaelKubovic commentedApr 21, 2021 via email
I believe it is always the case with direct exchange. The default exchange is a direct exchange with no name (empty string) pre-declared by the broker. It has one special property that makes it very useful for simple applications: every queue that is created is automatically bound to it with a routing key which is the same as the queue name. … On 21 Apr 2021, at 15:40, Tobias Nyholm ***@***.***> wrote:@Nyholm commented on this pull request. In src/Symfony/Component/Messenger/Bridge/Amqp/Transport/AmqpStamp.php: > @@ -45,7 +46,7 @@ public function getAttributes(): array return $this->attributes; } - public static function createFromAmqpEnvelope(\AMQPEnvelope $amqpEnvelope, self $previousStamp = null): self + public static function createFromAmqpEnvelope(\AMQPEnvelope $amqpEnvelope, self $previousStamp = null, string $retryRoutingKey = null): self Are we sure the routing key always matches the queue name? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. |
Nyholm commentedMay 10, 2021
Thank you@theravel and@MichaelKubovic for confirming. |
Nyholm commentedMay 10, 2021
Thank your for this feature. Please update the docs too =) |
Uh oh!
There was an error while loading.Please reload this page.
Added ability to distinguish retry and delay actions so that different "x-dead-letter-exchange" exchange name will be used in different scenarios.
This is a bug which existed since v4.4. The following scenario is possible:
AandB, both are bound to the same routing key via "topic" exchange (two different applications for example).Ahandles it correctly and acknowledges the message.Bthrows and exception and message goes to retry (for example to queuedelay_delays_key_5).delay_delays_key_5, it is delivered again to bothAandB(again consumed by consumerA).Expected: behavior of consumer
Bshould not cause message duplication to queueA.It is required to make a change of name of temporary delay queue (otherwise "delay" and "retry" queues have incompatible declaration arguments). I left
queue_name_patternas is to keep settings of connection backward compatible, but changed internals of queue name construction.