I have a topic and a subscription that are handled in an azure web job, but some messages should be moved to a dead letter (queue or topic?) after a certain amount of retries. I have no idea what it takes to handle dead letter messages. Does somebody has a code example? Is this possible with azure web jobs?
I'm almost giving up and doing it manually using a retry counter. For the time being, this what I'm doing, but I do not really like the idea to add the message back to the same queue:
public void SynchronizeConsumer(
[ServiceBusTrigger("topic")] Consumer consumer,
[ServiceBus("topic")] ICollector withError)
{
try
{
this.consumerSync.SyncConsumer(consumer);
}
catch (Exception ex)
{
consumer.NbOfRetries++; consumersWithError.Add(consumer);
}
}