<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
[HELP] Unable to consume reply message from MQ Queue
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/sjunejo">Sheeraz Junejo</a> in <i>JBoss ESB Development</i> - <a href="http://community.jboss.org/message/574484#574484">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><table border="0" cellpadding="3" cellspacing="1" style="width: 856px; height: 1310px;"><tbody><tr><td class="row2" height="28" style="" valign="top" width="100%"><table border="0" cellpadding="0" cellspacing="0" style="width: 694px; height: 1317px;"><tbody><tr><td style="">Hi, <br/> <br/> I am having problem consuming messages from MQ Server Queue. I am using  WebSphere MQ Server 7 with my web application to put messages on IN  Queue which will then Consume by my MDB deployed on jBoss and put reply  back on OUT Queue. <br/> <br/> My web application is deployed on jBoss 4.2.3 and I am using MQ Resource Adapter to connect to MQ Server. <br/> <br/> I am able to successfully put message on IN Queue where MDB is listening  which consume the messages, do some processing and put reply back on  OUT Queue where my web application is waiting for a response but it get  TIMED OUT. I mean I can see the response in MQ Explorer which is just  sitting there waiting to be consumed but my web application can not  recognize for some reason. <br/> <br/> I have tried with simpler Co-relation ID like '1' but didn't work. I am using following code to do all of the above; <br/> <br/> <table align="center" border="0" cellpadding="3" cellspacing="1" style="width: 90%;"><tbody><tr><td style=""><strong>Code:</strong></td></tr><tr><td class="code" style=""><br/> Connection connection = null; <br/> Session session = null; <br/> MessageProducer producer = null; <br/> Destination reqQueue = null; <br/> Destination repQueue = null; <br/> try { <br/> timeStart = System.currentTimeMillis(); <br/> InitialContext ctx = new InitialContext(); // Initial Context of type JMS Connection Factory <br/> Object factoryObj = ctx.lookup(jmsCxFactory); <br/> ConnectionFactory cxf = (ConnectionFactory)factoryObj; <br/> <br/> connection = cxf.createConnection(); <br/> session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); <br/> connection.start(); <br/> _serviceLocator = new ServiceLocator(); // Look up queues <br/> reqQueue = _serviceLocator.lookupDestination("queue/INQueue"); <br/> repQueue = _serviceLocator.lookupDestination("queue/OUTQueue"); <br/> producer = session.createProducer(reqQueue); // Register a producer <br/> Message jmsMsg = session.createTextMessage(message); // Assign request  to Message object so we can send it to Database Server later. <br/> jmsMsg.setJMSReplyTo(repQueue); // Preparing a class to wait for a response on Response queue <br/> producer.setDisableMessageID(false); // Make sure messages gets an id <br/> String correlationId = "1"; // Get and set unique Correlation ID so we can receive correct messages <br/> jmsMsg.setJMSCorrelationID(correlationId); <br/> jmsMsg.setStringProperty("FORMAT", pingLevel); // Set the message format <br/> producer.send(jmsMsg); // Put message on Queue <br/> MessageConsumer receiver = session.createConsumer(repQueue, "JMSCorrelationID='" + correlationId + "'"); // Now receive message <br/> long JMSConnectionTimeout = 5000L; // Set timeout value - Default 10 Sec. <br/> Message reply = receiver.receive(JMSConnectionTimeout); // Now receive a response <br/> if (reply instanceof TextMessage) { <br/> String response = ((TextMessage)reply).getText(); <br/> passedReq++; // Increment in the passed request counter <br/> } else { <br/> finalResponse += "Request : Timed Out..."; <--- Always timed Out and control ends up here <br/> failedReq++; // Increment in number of time out requests <br/> } <br/> } <br/> catch (NamingException e) { <br/> finalResponse += "Error Occured : Naming Exception - " + e.getMessage(); <br/> } <br/> catch (JMSException e) { <br/> finalResponse += "Error Occured : JMS Exception - " + e.getMessage(); <br/> } <br/> catch (RuntimeException e) { <br/> finalResponse += "Error Occured : Runtime Exception - " + e.getMessage(); <br/> } <br/> finally { <br/> closeResource(producer); <br/> closeResource(connection); <br/> closeResource(session); <br/> } <br/> </td></tr></tbody></table><br/> <br/> <br/> Does anyone know what could be the reason and why its happening? Your help and comments will be appreciated. <br/> <br/> Thanks <br/> <br/> -- <br/> <br/> SJunejo</td></tr></tbody></table></td></tr><tr><td class="row6" style="" valign="middle"><br/></td><td class="row6" height="20" nowrap="nowrap" style="" valign="bottom" width="100%"><table border="0" cellpadding="0" cellspacing="0" style="width: 18px; height: 18px;"><tbody><tr><td nowrap="nowrap" style="" valign="middle"><br/></td><td style=""><br/></td></tr></tbody></table></td></tr></tbody></table></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/574484#574484">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss ESB Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2032">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>