|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
JMS vs Java MQ - error when sending message with JMS |
« View previous topic :: View next topic » |
Author |
Message
|
DirkMaes |
Posted: Tue Sep 16, 2008 1:30 am Post subject: JMS vs Java MQ - error when sending message with JMS |
|
|
Newbie
Joined: 08 Jun 2007 Posts: 5
|
hi,
I have a question regarding JMS and the base MQ classes. When I send a message via the base MQ classes everything works fine but with JMS I always get an MQ error code 2009. I'm running both programs from the same environment (RAD) and the same Java project (so all libraries are the same). The queue manager and queue is the same for both programs.
Code for base MQ part
public class WmqSender {
protected static String MQ_QUEUE_MANAGER = "S12M0032";
protected static String MQ_SERVER = "S12M0032";
protected static String MQ_CHANNEL = "CL.S12M0032";
protected static String MQ_QUEUE_NAME = "APPL.STD.DNFOTMP1";
protected static int MQ_PORT = 1414;
public static void main(String[] args) {
try {
initClientConnection();
MQQueueManager queueManager = new MQQueueManager(MQ_QUEUE_MANAGER);
int openOptions = MQC.MQOO_INQUIRE | MQC.MQOO_OUTPUT;
MQQueue queue = queueManager.accessQueue(MQ_QUEUE_NAME, openOptions, null, null, null);
String message = "testkes";
MQMessage mqMessage = new MQMessage();
mqMessage.format = "MQSTR";
mqMessage.writeString(message);
queue.put(mqMessage);
queue.close();
queueManager.close();
} catch (MQException me) {
me.printStackTrace();
} catch (IOException ie) {
ie.printStackTrace();
}
}
private static void initClientConnection() {
MQEnvironment.hostname = MQ_SERVER;
MQEnvironment.channel = MQ_CHANNEL;
MQEnvironment.port = MQ_PORT;
}
Code for JMS part
public class JmsSender {
public static void main(String[] args) {
try {
MQQueueConnectionFactory connectionFactory = new MQQueueConnectionFactory();
connectionFactory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
connectionFactory.setHostName("S12M0032");
connectionFactory.setQueueManager("S12M0032");
connectionFactory.setChannel("CL.S12M0032");
connectionFactory.setPort(1414);
Connection conn = connectionFactory.createConnection();
Session session = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
Destination q = session.createQueue("APPL.STD.DNFOTMP1");
MessageProducer sender = session.createProducer(q);
TextMessage textMessage = session.createTextMessage();
textMessage.setText("testke");
conn.start();
sender.send(textMessage);
sender.close();
session.commit();
session.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Error message
javax.jms.JMSException: MQJMS2007: failed to send message to MQ queue
at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:553)
at com.ibm.mq.jms.MQMessageProducer.sendInternal(MQMessageProducer.java:1589)
at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1012)
at com.ibm.mq.jms.MQMessageProducer.send(MQMessageProducer.java:1046)
at com.test.jms.JmsSender.main(JmsSender.java:39)
Linked exception
com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2009
Any idea?
Thanks a lot
Dirk |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Sep 16, 2008 1:12 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
What happens if you change this:
Quote: |
connectionFactory.setHostName("S12M0032");
connectionFactory.setQueueManager("S12M0032");
connectionFactory.setChannel("CL.S12M0032");
connectionFactory.setPort(1414);
|
TO
Code: |
connectionFactory.setHostName(MQ_SERVER);
connectionFactory.setQueueManager(MQ_QUEUE_MANAGER);
connectionFactory.setChannel(MQ_CHANNEL);
connectionFactory.setPort(MQ_PORT);
|
These seem to have worked fine for MQEnvironment. Reuse them for the qcf.
This should prevent typo errors.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
DirkMaes |
Posted: Wed Sep 17, 2008 3:30 am Post subject: |
|
|
Newbie
Joined: 08 Jun 2007 Posts: 5
|
Unfortunately that didn't solve the issue
Dirk |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Sep 17, 2008 7:57 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Assuming that this is not due to some weird network stuff, the only other thing I can think of right now is for you to check that you have ALL the jars from mqinstall/java/lib on your classpath, and if you are running 64 bit java, that you have also the mqinstall/java/lib64 jars on your classpath (mind the order lib64 before lib)
If this does not resolve it, open a PMR! _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|