Reputation: 1
I'm trying to configure Jms and WebSphere using java and using Jboss 6.3 in remote system.But am getting ClassNotFoundException in creation of MQQueueConnection Class.Here I please fine code. Actually M not getting proper steps that what to do,I took help from IBM Knowledge Center but that is not helpful for me. Please anyone who knows about it guide me and for below code Which jar files is required?
try {
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
// Config
cf.setHostName("167.190.249.202");
cf.setPort(1422);
cf.setTransportType(WMQConstants.WMQ_CM_CLIENT);
cf.setQueueManager("QM.EMPIRE");
cf.setChannel("EMPIRE.CONN");
MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection();
MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
MQQueue queue = (MQQueue) session.createQueue("queue:///Q1");
MQQueueSender sender = (MQQueueSender) session.createSender(queue);
MQQueueReceiver receiver = (MQQueueReceiver) session.createReceiver(queue);
long uniqueNumber = System.currentTimeMillis() % 1000;
JMSTextMessage message = (JMSTextMessage) session.createTextMessage("SimplePTP "+ uniqueNumber);
// Start the connection
connection.start();
sender.send(message);
System.out.println("Sent message:\\n" + message);
JMSMessage receivedMessage = (JMSMessage) receiver.receive(10000);
System.out.println("\\nReceived message:\\n" + receivedMessage);
sender.close();
receiver.close();
session.close();
connection.close();
System.out.println("\\nSUCCESS\\n");
}
catch (JMSException jmsex) {
System.out.println(jmsex);
System.out.println("\\nFAILURE\\n");
}
catch (Exception ex) {
System.out.println(ex);
System.out.println("\\nFAILURE\\n");
}
}
}
Upvotes: 0
Views: 378
Reputation: 7506
It is far better to point your CLASSPATH to where the MQ JAR files are installed rather than copy the MQ JAR files (i.e. you won't get the 'ClassNotFoundException' error).
But if you do copy the MQ JAR files then for an MQ JMS application, you pretty much need all of them:
Upvotes: 1