I am trying to implement a message receiver in a Blazor Server web application.
The code for this operation is pretty straight forward.
- Inject a ServiceBusClient in the specific page.
- Create a Processor for a specific topic and subscription.
- Use the processor to connect the event handler for that subscription.
My goal with this implementation is that each client loading that specific page should receive the messages, but it isn't really working like that.
If two clients are loading the same page, one of them is getting the message. The next time a message is sent, it could be the other page that receives is.
Something tells me that this is due to the fact that the injected service is a singleton service and that it doesnt help that the message handler is connected twice.
I am not a specialist in this so this will be my best guess, but I was hoping that someone can guide me to do the proper implementation in order to get the desired result.
I have tried to retreive the service on the page inside a scope (using servicefactory but that doesnt work at all.
I have referred this MSDOC for Azure Service Bus client library for .NET Developers.