alekitto / messenger-extra

Additional transports and serializer support for symfony messenger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failing messages are retried continously and never bail out

arendjantetteroo opened this issue · comments

I've setup a failure transport like in the symfony docs:
https://symfony.com/blog/new-in-symfony-4-3-messenger-failure-transport

I was expecting failed messages to end up in the failure transport but if i use the mongo transport for my normal queue it keeps on retrying failed messages. It seems it doesn't keep track of the number of times a message fails.

If i understand the symfony defaults, it should bail out after 3 failed attempts and put the message in the failure queue.

If i use either the redis or amqp transports from messenger, the message is rejected after 3 tries (which also are not attempted at same time but with more delays each time).

And finally returns this, which is what i would also expect on the mongo transport behaviour.
10:24:41 INFO [messenger] Rejected message MyCommand will be sent to the failure transport Kcs\MessengerExtra\Transport\Mongo\MongoTransport.
[
"class" => "MyCommand",
"transport" => "Kcs\MessengerExtra\Transport\Mongo\MongoTransport"
]

I looked at the code and it might be the reject function should do something differently then the ack() function.

Any hints on where/how i should tackle this?

I digged a little bit into the messenger component and I think that only the Worker class is responsbile to forward failed messages to the failure transport.
But it seems to rely on the RedeliveryStamp to know when to forward it and the send methods are removing that stamp. Have you tried to remove the withoutStamp call here (and the corresponding call in the MongoSender class)?

I've investigated the problem for one of my projects, I discovered that removing the RedeliveryStamp from the Envelope is the root cause of the issue.
I've adapted the code to fix this.