Tuesday, June 12, 2012

JMS Queue in a Clustered Environment

Using JMS queues is quite simple once set up correctly.

But the simpleness immediately disappears when working in a clustered environment, whichever technology you are using; often you'll get NameNotFoundException or JMSException: Connection not found while trying to contact the JMS server.

The reasons can be many, but most of the time the problem is in the JNDI Lookup procedure: in a clustered environment, is important to preserve uniqueness of server names, to avoid the needs of complex tricks and the appearance of weird and mysterious errors.

A Technote from IBM explains that, in a Websphere clustered environment
"...in which 2 nodes have Application Servers with the same name, an attempt to lookup an EJB in the name space during an EJB invocation finds the wrong server.
[...]
The solution for this problem is to have different server names for the servers for 2 different nodes."

This happens because both Application Servers on different nodes have same name (server1 in the example), and trying to lookup server1 on ejb node from application node will instead return the server1 of application node, the local one.

The same thing happens on Weblogic, as they states in JMS Admin documentation (page 55):

"Note: JMS clients depend on unique WebLogic Server names to successfully access a cluster — even when WebLogic Servers reside in different domains. Therefore, make sure that all WebLogic Servers that JMS clients contact have unique server names."

Different server names, correct Lookups. That's all folks.

Hope that helps ;)

1 comment: