Reputation: 1579
I have a webjob that gets triggered by queue messages. If the job gets too long, The message reappears on the queue and a new instance of the webjob is triggered consuming the same message. That is not meant to be.
How can set the timespan while a message is hidden on the queue before reappearing?
Upvotes: 0
Views: 226
Reputation: 71029
Azure Queue messages have a visibility timeout value (in seconds), which you can set programmatically at any time, prior to the message becoming visible again.
You haven't mentioned what language you're coding in, but from a raw REST API standpoint, you just need to do an update message operation (a PUT
on the queue message). From the documentation:
https://myaccount.queue.core.windows.net/myqueue/messages/messageid?popreceipt=<string-value>&visibilitytimeout=<int-seconds>
Via .net (c#):
var message = queue.GetMessage();
queue.UpdateMessage(message,
TimeSpan.FromSeconds(30),
MessageUpdateFields.Visibility);
See here for the API call details.
Upvotes: 1