-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
In Azure/azure-sdk-for-net#18527, users pointed out that having the ability to end processing for a session early (i.e. not waiting for the receive call to timeout which is the switching mechanism used in the .NET SDK) is important for various scenarios:
- sparse sessions - if a session only ever contains a single message, it should be closed immediately after processing to save time
- handler knows that it cannot process a particular session anymore for some application-specific reason
This was supported in Microsoft.Azure.ServiceBus since the MessageSession inherited from the receiver types and could be closed directly. The approach used in Azure.Messaging.ServiceBus is a bit more nuanced since there could be multiple threads processing a single session at once. Also, we would want to make sure AutoComplete still works rather than just closing the link immediately. Thus, the ReleaseSession method that was added in Azure/azure-sdk-for-net#22525 does not immediately close the session, but signals to the processor that no new messages should be received from the session - once all processing is done for the session the link is closed.