Service Bus Queue messages lock not auto renewing
See original GitHub issueIt seems that messages on a Service Bus Queue are not getting the lock auto renewed.
I’ve tried AutoRenewTimeout on the MessageOptions and tried using OnMessageReceived which is supposed to auto renew. But when testing in a console app it does not auto renew, the lock is lost and the message is processed again.
I’ve been testing a with a short delay to mimic a long running task. I’ve tried the latest beta versions 2.0.0 and v1.1.2 both have the same behaviour.
static void Main()
{
var config = new JobHostConfiguration(_azureWebJobsDashboard);
ServiceBusConfiguration sbc = new ServiceBusConfiguration();
sbc.MessageOptions.AutoRenewTimeout = TimeSpan.FromSeconds(20);
config.UseServiceBus(sbc);
var host = new JobHost(config);
host.RunAndBlock();
}
public async static Task ProcessQueueMessage([ServiceBusTrigger("queue")] BrokeredMessage message, TextWriter log)
{
Console.WriteLine("Message received.");
Thread.Sleep(12 * 1000); // 12 seconds, lock is set to 10 seconds
Console.WriteLine("Message Complete.");
}
The only way I’ve been able to get the lock to renew is by adding a timer to renew it as mentioned on this post: http://stackoverflow.com/questions/27953882/guidance-onmessageoptions-autorenewtimeout
I found the azure sample also had the same behaviour I am experiencing.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Autotmatically renewing locks correctly on Azure Service Bus
I would not set AutoRenewTimeout to two minutes as it defeats the purpose of the setting. Have it somewhat larger than MaxLockDuration as...
Read more >Azure Service Bus message transfers, locks, and settlement
The client owning the lock can renew the message lock by using methods on the receiver object. Instead, you can use the automatic...
Read more >ServiceBusReceiverOptions interface
The maximum duration, in milliseconds, that the lock on the message will be renewed automatically by the client. This auto renewal stops once...
Read more >Azure Service Bus lock renewal
Message lock renewal applies to only the message currently being processed. Prefetched messages that are not handled within the LockDuration ...
Read more >[service-bus] lock auto renewal - use the lock token (rather ...
Auto -lock renewal currently tracks the lock renewals for messages using the message ID as the unique key. Message ID is not required...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well after lots of reading and debugging I’ve finally found the issue.
It was the Time on my pc. I decided to do a test by setting the Time on my pc to UTC Coordinated Universal Time (it was initially set to UTC +00:00 London) and the locks successfully automatically renewed!
I then set the time back to UTC London and it continued to work. It stops working again if I manually adjust the time to be incorrect by a minute or so.
So I would assume that the time on my pc was out slightly
Perhaps yes, a comment on this thread about Clock Drift gave me the idea to check the time http://stackoverflow.com/questions/21433482/why-does-brokeredmessage-renewlock-only-renew-the-lock-for-a-few-seconds
Anyway, thanks for your help.