Keep RabbitMQ running 24/7 with Service Protector

How to Keep RabbitMQ Running 24/7 with Service Protector

Automatically restart the RabbitMQ Windows Service when it crashes or stops listening for messages. Guard against memory leaks, CPU hogging and much more.

RabbitMQ provides robust asynchronous messaging for complex applications. It runs as a Windows Service with the Erlang service wrapper, as shown here in services.msc:

To monitor and protect RabbitMQ with Service Protector:

  1. Download and install Service Protector, if necessary.

  2. Start Service Protector.

  3. Select Protector > Add to open the Add Protector window:

    Add Protector

  4. On the General tab, in the Service to protect dropdown, choose the RabbitMQ service, named RabbitMQ. You will notice a green circle on the left if the service is already running, as pictured below.

    RabbitMQ Windows Service: General Tab

  5. If you are interested in monitoring RabbitMQ and detecting when it stops listening on its network port (5672 by default), click over to the Monitor tab. We'll set up a failure detection script to tell Service Protector when RabbitMQ has run into trouble.

    1. Follow these instructions to create the failure detection BAT file. We have called ours check-rabbitmq-listening.bat and placed it in C:\PortQry.

    2. Check the Whenever it fails a "sanity check" box and click the "..." button to open the Configure Sanity Check window. Enter the full path to the batch file.

      Change the Every controls to 5 minutes or set it to any value that you find appropriate. Feel free to reduce the time if you want to check the port more often.

      Press the OK button to save your sanity check settings.

    RabbitMQ Windows Service: Monitor Tab

  6. Click the Save button. In a couple of seconds, an entry for RabbitMQ will show up in the Service Protector window. RabbitMQ is probably already running but it is not yet being protected by Service Protector (as shown below).

    RabbitMQ Windows Service: Created

  7. To start protection, choose Protector > Start "Windows Service". The shield icon will go to green to indicate that RabbitMQ is being protected by Service Protector. Clicking on the shield will show a popup with some basic information:

    RabbitMQ Windows Service: Running

  8. That's it! Next time your computer boots, RabbitMQ will start as normal and Service Protector will begin monitoring RabbitMQ to promptly restart it if it fails.

    We encourage you to edit RabbitMQ in Service Protector and check out the many other settings that may be appropriate for your environment. For example, send an email when the service fails, monitor RabbitMQ's CPU usage and much more.

Trouble protecting the RabbitMQ Windows Service?