-
-
Notifications
You must be signed in to change notification settings - Fork 244
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
Propagate exceptions raised by subscriber message handlers #262
Conversation
I've made some modifications that I think might be less of a change to the original code. I've removed the option which I agree wasn't great. The only real difference now from the original code is that the call to So this handles the problem that one "bad" subscriber can stop message delivery to all the others while also running them in parallel. The only thing I'm a bit unsure about is whether it's a problem to throw an exception now that was being swallowed before? |
I think this is better now. Can you clean up the whitespace and other minor changes so we can keep this PR small and focused. |
Sure thing. Changes are as small as I could make them now I think. |
I have to apologise, but a bit further testing showed that, for reasons I haven't fully got to the bottom of yet, the way the task was created that was being waited on when sending messages wasn't propagating any exception correctly. Something about the way the I've refactored that part of the code and it's now working as I expected. ... It turns out that Anyway, the code is working as I expected now. |
This is looking good, but I'm concerned about using Task.WaitAll and it not being async. Seems like that is going to be a sync over async call which is dangerous. Can't we just do |
Also, I'd like for us to add a test that shows that multiple good subscribers and one bad one will work as expected and call all of the subscribers even though the one is going to blow up. Maybe register 2 good ones and then 1 bad one and then another 2 good ones and then verify that all of the good ones are called and that the error message (aggregateexception) is bubbled up like you are wanting it to be. |
I'd tend to agree, although that will change the entire |
I've added to the already existing test Confirming the exception contains the appropriate message is a little harder to put into the base functionality as it's really an implementation thing I think. For example, to pass that test I had to change the Thoughts? |
Yeah, I think we need to make that change because doing sync over async could potentially result in deadlocks. |
Ahh, I see it now. Yes, that is good. Thanks! |
Ok all done I think. The build failed but I'm not sure it's anything to do with the code I've changed so hopefully it'll be ok this time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is all done now?
Sorry, I'm out on vacation. I think the changes are good, but we just need to verify that we didn't break anything. I'll be out for another couple weeks. Maybe @niemyjski can take a look and see what he thinks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me, I'm just concerned about not seeing some bugs due to not logging on the outside of the when all and just eating exceptions. Can we move this logging up a little and then we'll merge it and do some additional testing. Thanks again for the PR.
…o subscribers fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your efforts on this @jcono. Sorry it took so long.
When using the AzureServiceBus the best way to guarantee the delivery of messages is to use
ReceiveMode.PeekLock
on the subscription client. For details see FoundatioFx/Foundatio.AzureServiceBus#38.In order for this to work correctly the handler of a message needs to be able to throw an exception up to the subscription client. These changes allow that to happen by optionally running the handlers sequentially rather than in parallel in a task as they are by default so that if a handler throws an exception it can be handled by the underlying client.