-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Context
In order to use the dead-lettering feature after Max delivery count. We want the message to stay on the queue with the lock. So the lock will expire. And the then the message could be retry.
Then the goal is to use Max delivery count, and Message lock duration for peek-lock
Messenger workflow
In error case :
1 -> messenger call 'reject' method on transport - (the stamp RedeliveryStamp is added) -> the message is deleted
2 -> messenger call 'send' method on transport to recreate the message
How to do
First option
Add a bundle option called for example : keep-locked-on-error: true (used only with peek-lock)
When a message is 'reject' and/or 'send' then check if RedeliveryStamp exists and keep-locked-on-error is true to prevent deletion and avoid re-send.
Second option
Implement a middleware which catch errors. When there is an error the middleware catch it and can add a custom stamp for example KeepLockedStamp.
But now we have 2 options :
- rethrow error -> its matches the "First option" and do not 'reject' and/or 'send' when the KeepLockedStamp is set.
- continue -> then 'ack' is called, check if KeepLockedStamp is set and do not delete.
I prefer the first option because it is relying more on messenger workflow.