-
Notifications
You must be signed in to change notification settings - Fork 593
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
The implementation of the AsyncEventingBasicConsumer is not safe when there are multiple handlers attached #838
Comments
I think I understand what is being asked here. This project is open-source and we would welcome a pull request that implements a solution with a test that demonstrates the problem with the current implementation. Thank you. |
While I'm not sure why you'd want multiple handlers attached to the the events, you are correct that the the way they are being invoked right now prevents that from working properly. I wouldn't to see LINQ introduced into this code path, though, so a foreach loop over the |
Microsoft does have an MIT licensed |
Good catch! |
Making sure AsyncEventHandlers are all run. Fixes issue #838.
The invocations of the events in
AsyncEventingBasicConsumer
are not safe when there are multiple handlers attached in a sense that they only await the handler that had been attached last.For example, the
Received
event is invoked like this:This invocation is starting the handlers one by one, and, as soon as one returns a
Task
, it moves to the next one. When it reaches the last handler, it grabs its resulting task and awaits only this singleTask
(orTask.CompletedTask
if the last handler happens to returnnull
). I suppose this is not intended.If the idea is to await all of the handlers (and, considering the remarks that state that "Handlers must copy or fully use delivery body before returning", it is), something along the lines of
may fix the issue.
P.s. I've initially asked the question in the mailing lists, but I guess it's more comfortable to discuss the code on github.
The text was updated successfully, but these errors were encountered: