Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

c# - Azure ServiceBus AutoRenewTimeout

I am using Azure ServiceBus Queues through the .net SDK. There is a flag on the OnMessageHandler/OnMessageOptions called "AutoRenewTimeout", but there seems to be confusion on what this value actually means.

On the official documentation here https://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.onmessageoptions.aspx it suggests that the AutoRenewTimeout should be greater than the queue lockduration.

Gets or sets the maximum duration within which the lock will be renewed automatically. This value should be greater than the longest message lock duration; for example, the LockDuration Property.

This seems to suggest that the AutoRenewTimeout is more or less the maximum time that it should take to process a message. e.g. If you have a lock duration of 1 minute, and an autorenewtimeout of 5 minutes, the message will be renewed a total of 5 times before giving up and making it visible on the queue again. There is also other StackOverflow answers confirming this to be the case e.g. https://stackoverflow.com/a/36051408

To handle long message processing you should set AutoRenewTimeout == 10 min (in your case). That means that lock will be renewed during these 10 minutes each time when LockDuration is expired.

So if for example your LockDuration is 3 minutes and AutoRenewTimeout is 10 minutes then every 3 minute lock will be automatically renewed (after 3 min, 6 min and 9 min) and lock will be automatically released after 12 minutes since message was consumed.

However on more research, I stumbled upon an old tweet (https://twitter.com/clemensv/status/649940087267041284) by what looks to be the Lead Architect for Messaging at Microsoft. In this tweet it seems to suggest that AutoRenewTimeout is instead the interval in which it will call the "RenewLock" method.

it's the interval in which https://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.brokeredmessage.renewlock.aspx is called on a message while the callback is active

So for example if your lockduration is 1 minute, the AutoRenewTimeout should be something like 30 seconds to ensure that the message lock is renewed before it gets released.

In my own tests, I'm leaning towards the former being correct, but the tweet is making me suspicious on the fact maybe I don't know the full use of AutoRenewTimeout

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your test is correct.

AutoRenewTimeout will allow to extend processing time beyond LockDuration w/o increasing the DeliveryCount. It should be set to the maximum processing time callback. Read it as a time range to wait for processing callback to complete. After that time OnMessage API will not issue a renewal.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...