...
Code Block | ||
---|---|---|
| ||
public override async Task ProcessMessageAsync(IMessageContext context, CancellationToken token) { // attempt to send message to a service var response = await service.Submit(context.message); if(response.NotReady) // service indicates the message cannot be processed yet // Call the ReprocessMessage method passing in a timespan for when we should retry context.ReprocessMessage(TimeSpan.FromMinutes(5)); } |
To place a message into the delayed state, call the context.ReprocessMessage(…) method passing in the amount of time the message should be delayed. This will change the queue type to D and the message will be skipped until the given time span has elapsed.
Once the time span has elapsed, the queue type will be reverted from D back to Q and the message will be dequeued again. There is no limit to the number of times a message can be delayed.
Info |
---|
Messages are reverted from Delayed to Queued periodically. This reversion will happen up to 2 minutes beyond the given delay time span. |
The queue user interface now includes 2 additional columns:
‘#Reprocess’ - the reprocess counter displays the number of times a message has been put into the delayed state.
‘Reprocess Date/Time’ - the date/time when the message will be revert back to a queued state.
You can also use the queue type drop-down within the queue to filter for delayed messages.
Info |
---|
There is no programmatic way to revert delayed messages to a queued state. This can be done manually using the ‘Reprocess…’ queue context menu items. |