How to put long running service into a .NET Rest API?
I am quite a C# newbie and need help with an architecture question. I want to build a C# API that provides an SSE route to send real-time messages to my frontend. The C# application will be connected to a RabbitMQ server. The goal is to send the processed message via SSE to the UI every time a message comes in through a RabbitMQ queue. How can I best integrate the RabbitMQ client into the C# application?
4 Replies
You create a class that handles the connection and dependency inject it as a singleton
So you only have to handle a single instance of it throughout the application.
If you use .NET 9+, then SSE support is built-in https://www.strathweb.com/2024/07/built-in-support-for-server-sent-events-in-net-9/
If you have no further questions, please use /close to mark the forum thread as answered
Thanks for the input 🙂 The Singleton solution seems to be perfect for my use case! Thanks 🙂