Although there is a Java API Java WMQ, as previous respondents noted, WMQ supports JMS, so here are some resources to get you started there.
Take a look at this article: IBM WebSphere Developer Technical Journal: Launching a stand-alone Java application on WebSphere MQ V6.0
In addition, if you installed the full WMQ client and didn’t just capture the banks, you will have a lot of sample code. By default, they will work in C: \ Program Files \ IBM \ WebSphere MQ \ tools \ jms or / opt / mqm / samp depending on your platform.
If you need WMQ Client installation media, get here . Please note that this is a WMQ v7 client, not a v6 client. It is compatible with v6 QMgr, but since v6 is the end of life as of September 2011, you should do new development on the v7 client and, if possible, v7 QMgr. There are many functional and performance improvements if both sides are v7.
You can get the product guide here if you need it.
Finally, be sure when you get a JMS exception to print the associated exception. This is not a WMQ thing, but a JMS thing. Sun has provided a layered data structure for JMS exceptions, and the really interesting parts are often at a nested level. This does not really matter and can be implemented in several lines:
try { . . code that might throw a JMSException . } catch (JMSException je) { System.err.println("caught "+je); Exception e = je.getLinkedException(); if (e != null) { System.err.println("linked exception: "+e); } else { System.err.println("No linked exception found."); } }
This helps determine the difference between a JMS error and a transport error. For example, a JMS security error may be WMQ 2035, or it may be a JSSE configuration, or the application may not have access to anything on the file system. Only one of them is worth spending a lot of time recoding WMQ error logs and only by printing the associated exception can you find out if it is one.