I am currently building two windows services:
The first takes messages from an internet connection and inserts these into a database. This is designed to be fast and stable and not do any other processing
The second performs a batch process with any new messages that have arrived since it last ran.
I am trying to think of a way so that the second service will only run its batch process when new messages are ready to be processed and if the second service errors the first service will keep going and vice versa. At the moment it uses a loop every 5 seconds.
I am currently thinking of using a message queue, where the first service writes a message only if the queue is empty, and the second service will see if the queue contains any messages, if not go into an asynchronous wait until a message arrives and then remove the message and run. Therefore using the queue not really as a queue but as a binary switch that when it's state changes causes an event to be triggered to the second service.
I presume there is a better way to do this that I have not encountered could someone please point me in the right direction?