You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
In some cases we don't want to handle the message right now, but we'd delay its execution for a X seconds and then check once again is it right time to process the message (if not, once again we delay it).
We have UnrecoverableMessageHandlingException to prevent retrying.
A good thing might to be have sth like DelayedMessageHandlingException with argument which defines when at earliest the message should be processed once again.
Example
Let's say we have a message which tells that we should import the data to database from specified file (ImportMessage). We don't want to process many imports at the same time, but we have multiple consumers runned.
In current case if two messages ImportMessage are possible to process in specified moment of time both will be executed in the same time and processed parallel. To prevent this we can make internal lock (for example using semaphore) to prevent second import from execution and delay all other imports for example for 30 seconds to process once again by throwing proposed DelayedMessageHandlingException.
The text was updated successfully, but these errors were encountered:
secit-pl
changed the title
Notifier - skip message for processing it later
[Messenger] Skip message for processing it later
May 23, 2020
This can be achieved in a custom middleware or in the message handler directly. Just re-dispatch the message with delay to the bus.
I don't think this needs to be added to the core.
@Tobion could you please explain a bit more how to "re-dispatch the message with delay to the bus"? The current doctrine transport implementation is executing this query every second (as I understood this transport is working):
SELECT m.* FROM messenger_messages m WHERE (m.delivered_at is null OR m.delivered_at < ?) AND (m.available_at <= ?) AND (m.queue_name = ?) ORDER BY available_at ASC LIMIT 1
I can't fid any simple way how to achieve the expected result without:
a) creating a new message in message handler sleeping (with sleep()) for a while before dispatching the message - this will block one consumer until the operation ends.
b) the same above but without sleep - this will spam the messages queue with many "nop" messages til the real expected execution time
Description
In some cases we don't want to handle the message right now, but we'd delay its execution for a X seconds and then check once again is it right time to process the message (if not, once again we delay it).
We have UnrecoverableMessageHandlingException to prevent retrying.
A good thing might to be have sth like DelayedMessageHandlingException with argument which defines when at earliest the message should be processed once again.
Example
Let's say we have a message which tells that we should import the data to database from specified file (ImportMessage). We don't want to process many imports at the same time, but we have multiple consumers runned.
In current case if two messages ImportMessage are possible to process in specified moment of time both will be executed in the same time and processed parallel. To prevent this we can make internal lock (for example using semaphore) to prevent second import from execution and delay all other imports for example for 30 seconds to process once again by throwing proposed DelayedMessageHandlingException.
The text was updated successfully, but these errors were encountered: