0

I have a queue receiver, which reads messages from the queue and process the message (do some processing and inserts some data to the azure table or retrieves the data).

What I observed was that any exception that my processing method (SendResponseAsync()) throws results in retry i.e. redelivery of the message to the default 10 times.

Can this behavior be customized i.e. I only retry for certain exception and ignore for other. Like if there is some network issue, then it makes sense to retry but if it is BadArgumentException(poisson message), then I may not want to retry.

Since retry is taken care by ServiceBus client library, can we customize this behavior ?

This is the code at the receiver end

public MessagingServer(QueueConfiguration config)
{
      this.requestQueueClient = QueueClient.CreateFromConnectionString(config.ConnectionString, config.QueueName);
      this.requestQueueClient.OnMessageAsync(this.DispatchReplyAsync);
}

private async Task DispatchReplyAsync(BrokeredMessage message)
{
     await this.SendResponseAsync(message);
}
alessandrio
  • 4,282
  • 2
  • 29
  • 40
Nishant
  • 407
  • 2
  • 4
  • 12
  • Can you share the code for `SendResponseAsync` method? – Gaurav Mantri May 26 '17 at 09:07
  • Inside SendResponseAsync, I am obtaining the requested message, performing some validation(which may throw InvalidArgsException() or NullReferenecException()) and writing to db. So the point was can we write something in DispatchReply or somewhere so that in case of NullReference it is not retried for 10 times and only in other cases/excpetions should retry happen. – Nishant May 26 '17 at 09:16

0 Answers0