0
votes

I have an Azure Web Job which is working by processing new items on an Azure storage queue. That is working. I have set the MaxDequeueCount to a low number, and once an operation triggered by a queue has failed that many times, I expect that this item on the queue to be moved to a poison queue.

However, that is not happening. The item gets removed from the queue, and there is no poison queue nor this message in any poison queue. What is wrong here, as I am unaware of any other steps required in order to have the message "pushed" to a poison queue.

 public static async Task ProcessQueueMessage([QueueTrigger("myQueue")] CloudQueueMessage message, TextWriter log)
    {
        try
        {
            throw new InvalidCastException();          
        }
        catch (Exception exception)
        {
            log.WriteLine($"Exception in ProcessQueueMessage: {exception}");
            throw;
        }
    }
1
Your function code is not failing the message processing. It is completing the processing with successful exception handing. You either choose not to handle the exception or rethrow the exception from the catch block after logging the message.Chetan
How so? if you look closely at the catch block, it is throwing the exception..user1060500
It is throwing exception... but also handling the exception.. you are not rethrowing is from the catch block.. if you are handling the exception and not rethrowing it that means you are aware of the exception and you are making sure that everything is good even after exception, that means message processing did not have any issue...Chetan
You are wrong. There is a throw statement there, but I think you didn't look closely after I told you the first time. (look at the end of the line in the catch block)user1060500
@user1060500 - This is a case where you should consider properly formatting your code to not have a throw at the end of the line. Without scrolling the code window, it's impossible to see it (yet you seem upset that people aren't looking "carefully" for something that's not obvious at all). And you've had to make several comments about this, including a comment on the posted answer. (fyi I edited this to be properly formatted)David Makogon

1 Answers

0
votes

The message will move to the poison queue only if there is an unhandled exception. Using a try-catch error is not the case. What you can do is to move the message to the poison queue manually in your catch section.