Version 15.5 introduces the new queue type (D)elay. Delay processing is a workflow where specific messages being dequeued cannot yet be processed, and should be retried later. However, other messages within the queue can be processed and should not be blocked.
Delay processing only applies to out-of-order message processing.
For example, let’s assume you need to send messages to an external service. This external service returns a 425 (too early) response code if the message cannot yet be handled and should be retried later. Other messages within the queue can be successfully processed and should not be blocked by those that cannot.
Your device (or Connexion custom code devices) can use the following pattern to delay the processing of a specific message:
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.
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.
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.