Search code examples
servicestackservicestack.redisredismqserver

How could I add a delay in processing failed messages in ServiceStack Redis MQ


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.


Solution

  • 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));