Search code examples
cachingrabbitmqmq

MQ Cache? good or bad idea?


I am wondering if MQ can be used as a state cache for monitoring? And is this a good idea or not?

In theory you can have many sources (monitoring agents) that detect problem states and distribute them to subscribers via an MQ system such as RabbitMQ. But has anyone heard of using MQ systems to cache the state, so when clients initialize, they read from the state queue before subscribing to new state messages? Is that a bad way to use MQ?

So to recap, a monitor would read current state from a state queue then setup a subscription queue to receive any new updates. And the state queue would be maintained by removing any alerts that are no longer valid by the monitoring agents that put the alert there to begin with.

Advantage would be decentralized notification and theoretically very salable by adding more mq systems to relay events.


Solution

  • I have a use case for Rabbit MQ that holds the last valid status of a system. When a new client of that system connects it receives the current status.

    It is so simple to do!

    You must use the Last Value Cache custom exchange https://github.com/simonmacmullen/rabbitmq-lvc-plugin

    Once installed you send all your status messages to that exchange. Each client that needs the status information will create a queue that will have the most recent status delivered to that queue on instantiation. After that it will continue to receive status updates.