Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Messenger] WorkerMessageRetriedEvent filled with not actual Envelope #52914

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

Closed
daffoxdev opened this issue Dec 6, 2023 · 2 comments
Closed

Comments

@daffoxdev
Copy link
Contributor

Description

Hi!

In Symfony\Component\Messenger\EventListener\SendFailedMessageForRetryListener exists following lines:

// re-send the message for retry
$this->getSenderForTransport($event->getReceiverName())->send($retryEnvelope);

$this->eventDispatcher?->dispatch(new WorkerMessageRetriedEvent($retryEnvelope, $event->getReceiverName()));

Why it's not passing newly created envelope in transport with new stamps to the event WorkerMessageRetriedEvent?
I mean:

// re-send the message for retry
$newEnvelope = $this->getSenderForTransport($event->getReceiverName())->send($retryEnvelope);

$this->eventDispatcher?->dispatch(new WorkerMessageRetriedEvent($newEnvelope, $event->getReceiverName()));

This leads to issue that this WorkerMessageRetriedEvent not know any data about inserted row to DB as $retryEnvelope is outdated after send() call. I need to get TransportMessageIdStamp by Doctrine for new inserted id, it stores in Envelope that returns by send, but current version not passing it further. It's impossible to do it in clear way here. Also if I have custom transport that adds some custom stamps that expected to be handled in this WorkerMessageRetriedEvent, it's is not possible currently.

Do you have any suggestions? And is current implementation 100% correct and it's not planning to change this place?

Example

No response

@daffoxdev daffoxdev changed the title WorkerMessageRetriedEvent filled with not actual Envelope [Messenger] WorkerMessageRetriedEvent filled with not actual Envelope Dec 7, 2023
@OskarStark OskarStark changed the title [Messenger] WorkerMessageRetriedEvent filled with not actual Envelope [Messenger] WorkerMessageRetriedEvent filled with not actual Envelope Dec 8, 2023
@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@carsonbot
Copy link

Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3

@xabbuh xabbuh removed the Stalled label Jul 4, 2024
@fabpot fabpot closed this as completed Jul 5, 2024
fabpot added a commit that referenced this issue Jul 5, 2024
…riedEvent` (daffoxdev)

This PR was merged into the 5.4 branch.

Discussion
----------

[Messenger] Passing actual `Envelope` to `WorkerMessageRetriedEvent`

| Q             | A
| ------------- | ---
| Branch?       |5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #52914
| License       | MIT

In `SendFailedMessageForRetryListener` fixed the `Envelope` instance that passes to `WorkerMessageRetriedEvent`. Now it is instance of `Envelope` the that is returned by transport sender and could include such stamps as `TransportMessageIdStamp`. Previously to the event passed the not actual envelope that is created before passed to `send()`

- changes in SendFailedMessageForRetryListener
- added new test for this case in `SendFailedMessageForRetryListenerTest`

Commits
-------

9b4cc57 [Messenger] Passing to `WorkerMessageRetriedEvent` envelope with actual stamps after sent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants