What's the proper way to abandon an Azure SB Message so that it becomes visible again in the future in a way I can control?

前端 未结 5 1780
梦谈多话
梦谈多话 2020-12-17 08:38

So the scenario is that I\'m using an SB queue to throttle outgoing callbacks to other services. One of the standard problems with calling back to other services is that the

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-17 09:02

    Feels a bit hacky, but the solution I came up with is

    try 
    {
       ...
    }
    catch (Exception ex)
    {
       await Task.Delay(30000);
       throw;
    }
    

    This way it will wait for 30 seconds before allowing it to abandon. It will eventually dead letter after the configured amount of times.

    I am using Azure Webjobs for receiving. Although I am using Task.Delay instead of Thread.Sleep it doesn't seem to be freeing up the thread to process another item from the queue while it awaits (by default, Webjobs processes 16 in parallel).

提交回复
热议问题