Ricardo Polo Jaramillo
Ricardo Polo Jaramillo

Reputation: 12328

Recoverable Azure Web Job (don't delete from queue)

In an Azure Web Job you can have functions triggered by an Azure queue in a continuously running job.

When a message has been read from a queue, it is deleted.

But if for some reason my Job crashes (think a VM restart) the current Job that was not finished will crash and I will lose the information in the message.

Is it possible to configure Azure Web Jobs not to delete messages from queue automatically, and do it manually when my job finishes?

Upvotes: 1

Views: 790

Answers (1)

Victor Hurdugaci
Victor Hurdugaci

Reputation: 28425

There are two cases:

  1. The function failed because the message was bad and we couldn't bind it - for example, you bind to an Person object but the message body is invalid JSON. In that case, we delete the message from the queue. We are going to have a mechanism of handling poison messages in a future release. (related question)
  2. The function failed because an exception was thrown after the message was bound - for example, your own code thrown an exception. Whenever we get a message from a queue (except in case #1) we set a lease of, I think, 10 minutes:
    • If the function still runs after 10 minutes, we renew the lease.
    • If the function completes, the message is deleted.
    • If the function throws for any reason, we leave the message there and not renew the lease again. The message will show up in the queue again after the lease time expires (max 10 minutes).

The answer your question, if the VM restarts you are in case #2 and the message should show up again after, at most, 10 minutes.

Upvotes: 3

Related Questions