| Author |
problem while reading message from reply queue using JMSCorrelationID
|
Ravichandramohan Pelluru
Greenhorn
Joined: Jul 20, 2005
Posts: 2
|
|
Hi, currently i am doing websphere migraiton from 4.0 to 5.1.0. i am facing a problem Problem description: A stateless session bean puts a message in a request queue, From the request queue a C++ Program (independent component) picks up the message, does some processing and Puts the response back in reply queue. The session bean then tries to read the message from the reply queue using QueueReciever and JMSCorrelationID in a separate JMS Session. But QueueReceiver is not able to pick the message from the reply queue. Using createBrowse I am able to read the messages in the reply queue. Observations: 1) Same code is working in Websphere 4.0, not working in websphere 5.1.0 3) I created one jsp which have JMS code to get the message using JMSCorrelationID. It is working fine. Note: it is reading the message from web container not from EJB Container Environmental Details: ===================== JDK 1.4.2_05-b04 Websphere 5.1.0 [base version] MQ Server 5.3 Stateless session bean: private QueueConnection qc = null; private QueuerequestQ = null; private QueuereplyQ = null; public void ejbCreate() throws javax.ejb.CreateException { InitialContext ctx = new InitialContext(); qcf = (QueueConnectionFactory) ctx.lookup("jms/QCF"); requestQ = (Queue) ctx.lookup("jms/RequestQueue"); replyQ = (Queue) ctx.lookup("jms/ReplyQueue"); qc = qcf.createQueueConnection(); } public void ejbRemove() { if(qc != null) qc.close(); } public String processRequest(String strMessage) { String CorrelationId = sendMessage(strMessage); String strReceiveMsg = receiveMessage(CorrelationId); return strReceiveMsg; } private String sendMessage(String cDataStream) throws javax.ejb.EJBException,javax.jms.JMSException,javax.naming.NamingException { QueueSession session = null; QueueSender sender = null; TextMessage message = null; String correlationId = null; try { // create a session. session = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); // create a QueueSender sender = session.createSender(requestQ); // create a message to send to the queue... message = session.createTextMessage(cDataStream); // send sender.send(message); // store the messageID as correlationID correlationId = message.getJMSMessageID(); } catch (JMSException je) { je.printStackTrace(); throw je; } finally { try { if (sender != null) sender.close(); if (session != null) session.close(); } catch (JMSException je) { je.printStackTrace(); throw je; } } return correlationId; } private String receiveMessage(String correlationId) throws javax.ejb.EJBException,javax.jms.JMSException,javax.naming.NamingException { QueueSession session = null; QueueReceiver receiver = null; TextMessage message = null; String messageSelector = "JMSCorrelationID=\'" + correlationId + "\'"; String msg = null; try { // start a connection qc.start(); // create a session. session = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); // create a QueueReceiver receiver = session.createReceiver(replyQ,messageSelector); // receive a message from the queue, wait 10 seconds try { message = (TextMessage) receiver.receive(10*1000); msg = message.getText(); } catch(Exception e) { e.printStackTrace(); } } catch (JMSException je) { je.printStackTrace(); throw je; } finally { try { if (receiver != null) receiver.close(); if (session != null) session.close(); if (qc != null) qc.stop(); } catch (JMSException je) { je.printStackTrace(); } } return msg; } Plz help i am unable to understand where i am wrong. ------------------------ Thanks & Regards Ravichandramohan
|
 |
 |
|
|
subject: problem while reading message from reply queue using JMSCorrelationID
|
|
|