Azure / azure-service-bus-dotnet

☁️ .NET Standard client library for Azure Service Bus
https://azure.microsoft.com/services/service-bus
Other
235 stars 120 forks source link

Allow MessageReceiver to process messages with peek lock before closing #649

Closed rangp closed 5 years ago

rangp commented 5 years ago

Actual Behavior

Calling MessageReceiver.CloseAsync stops the reception of messages but also closes the underlying service bus connection without waiting for processing of messages that are already fetched and have a peek lock. The message handler is expected to cancel ongoing tasks when CloseAsync is called.

Expected Behavior

For my use case I cannot cancel processing of messages halfway. Each message must be processed exactly once and prcoessing must be complete. I would expect a functionality that allows the active message handler tasks to finish before the service bus connection is closed so that the messages can be properly completed.

In my understanding after reading the source code it would be sufficient to cancel the MessageReceivePump separately to closing the MessageReceiver. I am missing a method like UnregisterMessageHandler that would allow me to end automatic message reception without losing the connection.

rangp commented 5 years ago

Okay, this seems to be a duplicate of #509. Would be extremely helpful to have this feature soon