I'm using an Azure Functions Queue Trigger to read in a queue message and process work in Python. I have my batchSize
parameter set to 1
to limit concurrency. In the Python code, I have an additional check to see if the work is ready to be processed as in:
if work is ready:
do_work()
else:
dequeue the message and try again
I want to dequeue the message if the work isn't ready to be processed and try again in one minute. I think I can achieve the retry by just setting visibilityTimeout
to 00:01:00
. But what is the best way to dequeue the message? Would it just be:
if work is ready:
do_work()
else:
raise Exception("work is not ready, dequeue the message")
Would this allow the message to be dequeued and picked up for a retry in one minute? This use case is fairly rare and I'm wondering if there is a better way because I'm not sure if I want to see the Error in my logs for this case.
Edit: is it possible to use initialVisibilityDelay
in my Python QueueTrigger? This would eliminate the need for me to throw an exception if I could delay the visibility of my messages by one minute.