I'am currently using the WebJobs SDK to consume messages issued in queue.
My method as one parameter with the [Microsoft.Azure.WebJobs.QueueTrigger(...)] attribute and is triggered alright. In some circumstances, the method can process the message but from time to time, I would prefer that it reject the message until a critical resource becomes available.
I tryed to throw an exception in this case, but contrary to what the reference says, the queue trigger is fired again immediately (apparently not waiting the lease time).
Is there a way to gracefuly postpone the message handling ? Would it be safe just to freeze the thread waiting for critical resource ?
Any hint would be much appreciated.
I don't think you can postpone a message in current version.
Possible workaround
You can re-add the same message with delay and to avoid duplicates you can set your
MaxDequeueCount
to1
, this will send failing message straight to poison queue after exception:and message processor - re-add your message with delay and throw exception:
This way you can implement some kind of back-off strategy for your resource. Unfortunately you have to manually deal with some problems:
NumberOfRetries
and increment it every time you re-add itId
andInsertionTime
will be different after every re-add so you can't rely on them.