Is there an easy way to get Servicestack to wait x seconds before retrying a failed MQ item (using Redis MQ). At the moment it just tries 3 times consecutively with no delay.
Asked
Active
Viewed 314 times
1 Answers
3
When you register a MQ handler you can also register an error handler which gets called after publishing a failed message which you can use to add a custom delay, e.g:
mqServer.RegisterHandler<MyRequest>(
ServiceController.ExecuteMessage,
(msgHandler, msg, ex) => Thread.Sleep(1000));

mythz
- 141,670
- 29
- 246
- 390
-
Just so I'm clear. The error handler finishes executing before the message gets retried/reposted to the queue? – richardwhatever May 26 '15 at 18:12
-
@richardwhatever it's fired after the error response is published, but can be used to delay that worker handler thread before it executes its next message. – mythz May 26 '15 at 18:46
-
1@mythz the solution you provided using Thread.Sleep can work but this is not durable, (i.e. in the case of system failure during 1 second wait). Is there anyway to not use a Thread.Sleep and chuck the failed msg back to the redis queue and somehow handle this msg later (i.e. don't dequeue until say 2 secs later). Maybe ZRANGE can help? – Jeff Oct 13 '15 at 03:10
-
@mythz actually, maybe I need to use DLQ to handle proper delayed retry. Instead of relying on SS to handle it for me. But NServiceBus does have it baked in. – Jeff Oct 13 '15 at 03:15