Question

I want to create a Java standalone application for connecting via JMS to an MQ Queue Manager (not to be confused with a client). I want to create the JNDI resources independently and put everything in a JAR a run it to make some tests.

Is there any example that I can take to build this?

Was it helpful?

Solution

Little old but explains the steps: IBM WebSphere Developer Technical Journal: Developing a standalone Java application for WebSphere MQ http://www.ibm.com/developerworks/websphere/techjournal/0502_woolf/0502_woolf.html

Then to access the JNDI you need the thin client http://pic.dhe.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.express.doc%2Finfo%2Fexp%2Fae%2Ftcli_developthin.html

There is also a sample in the client download JmsJndiProducer.java

OTHER TIPS

The Javadoc for the WebSphere MQ JMS classes can be found here. What you want to do is to create an instance of the com.ibm.mq.jms.MQConnectionFactory, com.ibm.mq.jms.MQQueueConnectionFactory or com.ibm.mq.jms.MQTopicConnectionFactory. Once you have an instance you can configure it using the various setters and then call one of the createConnection methods. A simple example would be:

MQConnectionFactory factory = new MQConnectionFactory();
factory.setQueueManager("myQmgr");
factory.setTransportType(WMQConstants.WMQ_CM_BINDINGS);

Connection conn = factory.createConnection();
Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue q = session.createQueue("myQ");
TextMessage msg = session.createTextMessage();
msg.setText("My message body");
MessageProducer sender = session.createProducer(q);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top