question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE REQ] Manual message lock renewal when using ServiceBusProcessor

See original GitHub issue

Library or service name. Azure.Messaging.ServiceBus

Is your feature request related to a problem? Please describe. I would like a way to manually renew the lock of a ServiceBusReceivedMessage when receiving messages through the ProcessMessageAsync message handler of a ServiceBusProcessor.

Using a ServiceBusReceiver to receive messages gives access to ServiceBusReceiver.RenewMessageLockAsync(ServiceBusReceivedMessage message, CancellationToken cancellationToken), but that call is unavailable through the ProcessMessageEventArgs argument of a ServiceBusProcess.ProcessMessageAsync message handler delegate.

I know there is the ServiceBusProcessorOptions.MaxAutoLockRenewalDuration option to use, but in my case a call may take anyway from less than a second, up to several hours. I want to be able to handle renewals manually, in order to make sure we are not stuck somewhere unexpected.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Stolpecommented, Oct 27, 2021

Luckily, I don’t use sessions, but thanks for letting me know.

0reactions
JoshLove-msftcommented, Oct 27, 2021

Ah, I understand now. I never realized I could create both a processor and a receiver, and use them interchangeably, but when I think of it it will probably be a perfectly good solution for me.

Thank you very much for your time, and have a nice day.

Yeah it works in this particular case because renewing a message lock doesn’t interfere with receiving messages. Interestingly, it would not work if you were using sessions as you need a session lock to renew the session, which means you couldn’t have both a processor and a receiver for the same session.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Autotmatically renewing locks correctly on Azure Service Bus
This thread and this thread gives great examples of how to manually renew the locks, but I thought there is a way to...
Read more >
[FEATURE REQ] ServiceBusProcessor with lock renewal ...
When the lock is lost, the "behind the scenes receive manager" could cancel the token source linked to the LockLostToken which then also...
Read more >
ServiceBusProcessor Class (Azure.Messaging.ServiceBus)
The message handler is specified with the ProcessMessageAsync property. ... Gets the maximum duration within which the lock will be renewed automatically.
Read more >
Azure Service Bus client library for .NET
It offers automatic completion of processed messages, automatic message lock renewal, and concurrent execution of user specified event handlers. Because of its ...
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found