0

I have 2 windows services in C#. Service 1 publishes messages to the RabbitMQ queue. Service 2 subscribes the RabbitMQ queue. Service 2 also connects to a TCP server and sends the messages it has received from RabbitMQ to this server. My question is, is there any way to stop Service 1 from publishing messages on to the queue when Service 2 which consumes this message has failed out due to some error (Mostly, SocketException if it cannot connect to the Server). Any pointer would be really helpful. Please let me know if any more information is required.

Thanks in Advance.

Minu
  • 232
  • 4
  • 13

1 Answers1

0

Just a few of my(opinionated) ideas on how to approach it:

  1. One option would be to create some sort of hartbeat messaging system between the two and check if the service is OK on intervals, this has the downside of somethings happening after you do one check and before the next.

  2. Another would be to add to Service 1 a lock flag to have it stop sending to Service 2 and toggle the flag by having Service 2 send a message back to Service 1 on an Exception, but for this again on intervals you will need to check when the calls start working again and toggling back Service 1 to an ON state.

  3. You could add exponential backoff to Service 1, this would have the upside of not flooding Service 2, and would also avoid the checks and ping-pong of messages, the downside is that the backoff time could grow really large.

Cheers

MarkovskI
  • 1,489
  • 2
  • 21
  • 25