I have a Windows service written in C # that is read from MSMQ and based on the type of message that it assigns to them the agents that process this message in the workflow. The application starts without agents and is created dynamically at runtime when messages arrive in MSMQ
Here is a basic figure of how this works:

If the agent workflow is busy doing work, the message is queued in its local queue. So far, so good. But if for some reason, if the service is stopped, the contents of the local queue are lost.
I am trying to figure out what might be the best way to handle this scenario. Right now, local queues are System.Concurrent.ConcurrentQueue . Maybe I could use Sql Ce db or some other persistent storage, but I'm worried about performance. Another thing, in my opinion, is to read MSMQ only when the agents are ready to process messages, but the problem is that I do not know which message MSMQ will contain.
What possible approaches can I take on this issue?
source share