|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Trying to read medssage from MQ and not being able to do so |
« View previous topic :: View next topic » |
Author |
Message
|
kumarprabhat |
Posted: Thu May 23, 2002 3:40 pm Post subject: Trying to read medssage from MQ and not being able to do so |
|
|
Newbie
Joined: 23 May 2002 Posts: 2
|
I am trying to read a message from a MQ Queue which gets posted on after a processing in WLPI. I am not able to read the message even though I can see it in MQS Explorer.
Any help????
Code: |
public static final String qcfLookup = "EDEV_APP_XA_PRICINGPOC";
public static final String icf = "com.sun.jndi.ldap.LdapCtxFactory";
public static final String url = "ldap://OAK-A0031887/ou=jms;ou=java;o=XYZ.COM";
public static void main(String[] args) {
MQQueueSession mqSession = null;
MQQueueConnection mqConnection = null;
MQQueueConnectionFactory mqFactory = null;
try {
Context ctx = initJNDI(icf, url);
mqFactory = getConnectionFactoryFromJNDI(ctx, qcfLookup);
mqConnection = (MQQueueConnection) mqFactory.createQueueConnection();
mqSession = (MQQueueSession) mqConnection.createQueueSession(false, mqSession.DUPS_OK_ACKNOWLEDGE);
MQQueue q1 = (MQQueue) mqSession.createQueue("PRICINGPOC.RATEREQ.IN");
MQQueueSender mqQueueSender = (MQQueueSender) mqSession.createSender(q1);
mqQueueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
TextMessage outMessage = mqSession.createTextMessage();
outMessage.clearProperties();
outMessage.setText("<?xml version='1.0'?><poc><Request><CustName>SONY</CustName><Activity>get</Activity></Request></poc>");
String corrId = "2";
int prty = 1;
outMessage.setJMSCorrelationID(corrId);
outMessage.setJMSPriority(1);
outMessage.setJMSExpiration(20000L);
mqQueueSender.send(outMessage);
MQQueue q2 = (MQQueue) mqSession.createQueue("PRICINGPOC.RATEREQ.OUT");
String selector = "JMSCorrelationID = " + corrId;
MQQueueReceiver mqQueueReceiver = (MQQueueReceiver) mqSession.createReceiver(q2, selector);
TextMessage msg = (TextMessage) mqQueueReceiver.receive(15000L);
if (msg != null) {
msg.acknowledge();
if ( ((String) msg.getJMSCorrelationID()).equals(corrId) ) {
System.out.println(msg.getText());
}
}
} catch (JMSException je) {
------------------------------------- |
[/code] |
|
Back to top |
|
 |
kolban |
Posted: Fri May 24, 2002 3:47 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2001 Posts: 1072 Location: Fort Worth, TX, USA
|
I can't tell you how many times I too have been bitten by this problem
The solution is easy, when you create a QueueConnection object, messages are not delivered to you until/unless you explicitly start the connection. There is a method on the QueueConnection class called start() that must be invoked before messages are delivered to the application. Call this before executing the receive and all should be well. |
|
Back to top |
|
 |
kumarprabhat |
Posted: Fri May 24, 2002 8:50 am Post subject: Thanx kolban...But the problem is still there.. It is a Sync |
|
|
Newbie
Joined: 23 May 2002 Posts: 2
|
Thanx kolban...But the problem is still there.. It is a Syncronous messaging that I am trying and am not able to...
This is the last hitch in my Proof of Concept and I am stuck.
Somebody...please.... |
|
Back to top |
|
 |
StefanSievert |
Posted: Fri May 24, 2002 10:37 am Post subject: |
|
|
 Partisan
Joined: 28 Oct 2001 Posts: 333 Location: San Francisco
|
Is it possible that you are putting to a different queue than the one you are trying to read from?
Beyond that, I think the correlationId is a byte field, not a string, but I am not sure if that might have an effect here.
Just two thoughts,
Stefan _________________ Stefan Sievert
IBM Certified * WebSphere MQ |
|
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
|
|
|
|