1
votes

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?

1
You can always just poll the queue manually. When you call .GetMessage(), it will mark the message as 'invisible' for 10 minutes, then when your job completes, call .DeleteMessage(). If your application crashes, the message will automatically return to the queue.ChadT

1 Answers

3
votes

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.