-
Notifications
You must be signed in to change notification settings - Fork 653
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
Published events are lost when published in a separate thread #5121
Comments
@ngallegos What you're trying to do isn't going to work. When using the You are calling The sample you've linked to shows an approach that can work for handling long-running operations. |
Ah okay. Thanks @bording! The problem with waiting for the task to complete is that it brings me back to the issue of a long running job inside a message handler. If the job runs for too long, the Azure queue will release the message and it will be processed again. I was hoping to avoid the exact solution in the sample because it looks as though I'd need to implement a separate queuing/processing system to handle these jobs. I've been using NServiceBus to migrate away from our existing queuing/processing system and was hoping that long-running jobs could migrate too. Sounds like I may be out of luck there. I did see something about message lock renewal, but the document suggests it should be avoided. Do you know why that is? |
|
@ngallegos you should use the timeout feature on a watchdog saga to check the completion of the spun off task. That is guaranteed to be invoked. That's how the sample does it as well. |
Great, thank you @SeanFeldman and @yvesgoeleven! I think the saga timeout will work nicely. I must have missed that in the sample. Thanks again for your time and responses. |
I've been working on getting long running messages working with NServiceBus on an Azure transport. Based off this document, I thought I could get away with firing off the long process in a separate thread, marking the event handler task as complete and then listening for custom OperationStarted or OperationComplete events. I noticed the OperationComplete event is not received by my handlers most cases. In fact, the only time it is received is when I publish it immediately after the OperationStarted event is published. Any actual processing in between somehow prevents the completion event from being received. Here is my code:
Abstract class used for long running messages
Test Implementation
Operation Events
Handlers
I'm certain that the
context.Publish()
calls are being hit because the_logger.Info()
calls are printing messages to my test console. I've also verified they are hit with breakpoints. In my testing, anything that runs longer than 500 milliseconds prevents the handling of the OperationComplete event.If anyone can offer suggestions as to why the OperationComplete event is not hitting the handler when any significant amount of time has passed in the ProcessMessage implementation, I'd be extremely grateful to hear them. Thanks!
The text was updated successfully, but these errors were encountered: