-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE REQ] Allow access to the session in the ServiceBusSessionProcessor #18527
Comments
Thank you for your feedback. Tagging and routing to the team best able to assist. |
Hey all, wanted to add a feedback point here, our team could use this one as well to be able to let a consumer of a session using the ServiceBusSessionProcessor close the session it's currently on and move on to something else, should something come up that it knows it can't process that particular one but some other handler may be able to. (Network issues, etc). |
Our team is using sessions to ensure that messages belonging to the same session are never processed in parallel. However, 95% of these sessions comprise only 1 message, meaning that each session will effectively idle for Allowing us to 'eagerly' close the session and release the session lock after completing each message, thus preventing the processor from automatically looking for another message on the same session that will never be there, would instantly eliminate the need to idle for single-message sessions. Is there another way for summarily locking related messages on the service bus that I'm not aware of? |
@sfrk there isn't another way to eagerly close the session. We would need to add support for it in the library. |
I need this feature as well and it used to be there in the Track 0 SDK (on MessageSession). |
Since this has been added to the July/Backlog milestones, does that mean some sort of solution is being worked on? |
Hi @esbenbach, I'd like to add the ability to close a session in our August release (possibly as a beta release). One complication is that multiple threads may be concurrently receiving from a single session, so we will need to be careful in how we handle Closing so as to not stomp on another thread's work, and also to not require each thread to call close on the same session. My thought is that in this scenario, the close call would signal that the session should be closed once all in-flight work is completed for that session. |
I haven't looked at the doc in a while... In the Microsoft.Azure.ServiceBus sdk the session handler was single threaded. You could handle multiple sessions but only one concurrent message per session. Are you saying the new sdk also allows multiple concurrent calls to the session handler? |
Yes, via the MaxConcurrentCallsPerSession option. |
Here is what I am thinking the behavior will be: |
@JoshLove-msft the description sounds reasonable. Its not really an issue, just that the description leaves me in doubt of how it works. |
It doesn't sound like all threads completing would have anything to do with message settlement. However it's not clear what happens in the other threads that didn't close the session. Do they also have to manually settle the message? If so then a user would need to implement some kind of sync with a session status flag maybe (?) so each thread knows how to settle the message. What is the purpose of disabling auto settlement in this close session scenario? |
These are great questions and perhaps the behavior becomes confusing when disabling the auto completion with MaxConcurrentCallsPerSession > 1. The scenario I was thinking about is where the user receives a message that they do not want to autocomplete and they want to close the session. I suppose this scenario isn't really specific to closing sessions. Users can always abandon the message themselves in this case. The other thing is that the semantics are a bit awkward when the CloseSession method does not actually close the session at that time. If we wanted to still allow autocompletion, we would have to have the method (or property maybe?) act as a signal to the processor that the session is marked for closing, rather than actually close the session at the time the method (or property) is called. |
I think the property / method in a multi message session handler would be acceptable. It should prevent the message pump from getting additional messages from the session and allow in-flight handlers to complete. When they have all completed it would close the session and acquire a new one. I don't think it should change the behavior of auto completion. As you say, abandoning the message would remain an option, and would be the typical method when auto complete is enabled anyway. |
Library or service name.
Azure.Messaging.ServiceBus
Is your feature request related to a problem? Please describe.
Allow access to the session in the ServiceBusSessionProcessor, giving the user control over when to close the session.
The feature and use cases were discussed in #16773.
#16773 (comment)
The text was updated successfully, but these errors were encountered: