Tuesday, January 08, 2008

JBoss WebsphereMQ Failover

IBM's MQSeries Message Broker doesn't have any built-in failover support. The reccomended solution is to use IP level takeover where a standby machine monitors the main machine via a heartbeat. If the heartbeat goes away, then the failover machine does IP takeover. Your clients will need to re-connect, but that should be all.

We didn't want to do that so instead I needed to have our MDBs and other JMS client code running in JBoss to failover to a different MQ server.

The solution I chose was to have an MBean that monitors the "main" server by listening on a "monitor" queue (just a normal queue created for monitoring purposes). When a failure is detected (by a JMS exception listener) it re-populates the MQ JMS objects in JNDI.

The MDBs will automatically try and re-connect when they detect a failure. Eventually, after the JNDI is updated to the new MQ server it will reconnect properly.

Other client code (MDBs that send messages, servlets that send/receive) need to know to re-connect when there is a failure. I created a notification system so that they can re-get any objects from JNDI after they are re-populated. In addition, any temporary queues that were created will need to be re-created since they now refer to the bad MQ server.

Hopefully, I can detail this out better over the next couple of weeks.