Reputation: 858
I started reading up on RabbitMQ to decide if we could use it for a new web project - and I am pretty excited right now :-)
All the samples I saw use some kind of while(true) loop in a console application as a consumer. What would be a solid and fault tolerant way to implement a consumer on a windows platform. I suppose a windows service? Has anybody done this and has it running in production and can maybe share his experience?
What I want to do is simply put the MQ on one server, pushing the messages in from a web app and use a 2nd server to connect to the MQ on the first server, poll for messages (every second) and execute some actions. Is this possible with RabbitMQ?
Thx Eau
Upvotes: 0
Views: 558
Reputation: 19295
What's wrong with while (true)
processing? As long as you have a mechanism in that loop to gracefully break out of it, it may be all you need. Integrating with the Windows SCM is fine too, you'll just have to watch for SCM events like SERVICE_CONTROL_STOP
within your service control handler function and react accordingly.
Yep, perfectly reasonable and very common. That said, there's probably no need to poll every second for new events. Just have your consumer start a thread that polls RabbitMQ indefinitely and processes events once they arrive. Otherwise you'll incur a whole lot of unnecessary polling traffic.
Upvotes: 1