Previously I wrote about using SMQueue to create simple consumers and producers for message queues. I also wrote about setting up a high availability message store. When a failure occurs, the message queue promotes the slave to master — but the producer and consumer I wrote will stubbornly keep trying to reconnect to the now-dead ex-master node.
With SMQueue 0.1.0, adding failover support is trivial. Where you create the SMQueue instance, just add a secondary_host key pointing at the second broker:
queue = SMQueue(
:name => "/queue/numbers.ascending",
:host => "mq1.domain.com",
:secondary_host => "mq2.domain.com",
:adapter => :StompAdapter
)
That's it. Your client will now fail over to the secondary broker when the primary goes down. I believe the plan is to support more than two broker nodes and pluggable failover strategies in future versions of SMQueue.