0

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;
        }
    }
David Makogon
  • 69,407
  • 21
  • 141
  • 189
user1060500
  • 1,505
  • 1
  • 21
  • 40
  • 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 Jun 17 '19 at 02:08
  • How so? if you look closely at the catch block, it is throwing the exception.. – user1060500 Jun 17 '19 at 03:08
  • 1
    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 Jun 17 '19 at 03:14
  • 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 Jun 17 '19 at 03:27
  • @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 Jun 17 '19 at 04:23
  • Thanks for the lesson. It's two separate lines in Visual Studio. For some reason it got appended all on one line when I put it into StackOverflow. Thanks for editing it. I didn't even think that most screens would require a horizontal scroll. On my old monitor, I see it clearly from end to end myself... (for the record, not upset, nor care. Just providing objective info and looking for help with this issue - if you can provide some, please let me know) – user1060500 Jun 17 '19 at 04:34
  • I test in my site and it works well and could push message into poison queue. Could you please show me more details like your webjob sdk and the version of Storage? – Joey Cai Jun 17 '19 at 05:33

1 Answers1

1

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.

Kamran
  • 1,258
  • 1
  • 16
  • 28