ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Trying to read medssage from MQ and not being able to do so

Post new topic  Reply to topic
 Trying to read medssage from MQ and not being able to do so « View previous topic :: View next topic » 
Author Message
kumarprabhat
PostPosted: Thu May 23, 2002 3:40 pm    Post subject: Trying to read medssage from MQ and not being able to do so Reply with quote

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
View user's profile Send private message
kolban
PostPosted: Fri May 24, 2002 3:47 am    Post subject: Reply with quote

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
View user's profile Send private message
kumarprabhat
PostPosted: Fri May 24, 2002 8:50 am    Post subject: Thanx kolban...But the problem is still there.. It is a Sync Reply with quote

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
View user's profile Send private message
StefanSievert
PostPosted: Fri May 24, 2002 10:37 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Trying to read medssage from MQ and not being able to do so
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.