• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

TimeOut in sending and receiving message in MQ5.3 thorugh RAD 8

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using EJB 3 MDB, websphere MQ V5.3and RAD V8 combination,have defined activation specification.I am sending one message in request MQ(REQUEST_QUEUE) then it is heating DB get some data and putting this response in another queue (RESPONSE_QUEUE),i am trying to read this RESPONCE_QUEUE through java code but getting time out exception as below.Code of send and receive is also attached below.Please advice.

Is this version related issue of web sphere MQ (As I am using MQ-V5.3)? OR Am I missing some code in java? OR Any setting in RAD8 server required?

0000001e TimeoutManage I WTRN0006W: Transaction 000001368307B819000000060C169F2488E5D793A026BBCB5982901AB3984096B231C220000001368307B819000000060C169F2488E5D793A026BBCB5982901AB3984096B231C22000000001 has timed out after 120 seconds.
4/5/12 20:35:02:968 IST 0000001e TimeoutManage I WTRN0124I: When the timeout occurred the thread with which the transaction is, or was most recently, associated was ThreadWebContainer : 0,5,main. The stack trace of this thread when the timeout occurred was:
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(SocketInputStream.java:140)
com.ibm.mq.jmqi.remote.internal.RemoteTCPConnection.receive(RemoteTCPConnection.java:1419)
com.ibm.mq.jmqi.remote.internal.RemoteHconn.receiveBuffer(RemoteHconn.java:1365)
com.ibm.mq.jmqi.remote.internal.RemoteHconn.receiveOneTSH(RemoteHconn.java:1329)
com.ibm.mq.jmqi.remote.internal.RemoteHconn.receive1stGetReplyTSH(RemoteHconn.java:1820)
com.ibm.mq.jmqi.remote.internal.RemoteFAP.jmqiGetMessageWithProps(RemoteFAP.java:7883)
com.ibm.mq.jmqi.remote.internal.RemoteFAP.MQGET(RemoteFAP.java:7652)
com.ibm.msg.client.wmq.v6.base.internal.MQSESSION.MQGET(MQSESSION.java:1009)
com.ibm.msg.client.wmq.v6.base.internal.MQQueue.getMsg2Int(MQQueue.java:1353)
com.ibm.msg.client.wmq.v6.base.internal.MQQueue.getMsg2(MQQueue.java:994)
com.ibm.msg.client.wmq.v6.jms.internal.MQMessageConsumer.getMessage(MQMessageConsumer.java:2751)
com.ibm.msg.client.wmq.v6.jms.internal.MQMessageConsumer.receiveInternal(MQMessageConsumer.java:4622)
com.ibm.msg.client.wmq.v6.jms.internal.MQMessageConsumer.receive(MQMessageConsumer.java:4091)
com.ibm.msg.client.jms.internal.JmsMessageConsumerImpl.receiveInboundMessage(JmsMessageConsumerImpl.java:780)
com.ibm.msg.client.jms.internal.JmsMessageConsumerImpl.receive(JmsMessageConsumerImpl.java:348)
com.ibm.mq.jms.MQMessageConsumer.receive(MQMessageConsumer.java:228)
com.ibm.ejs.jms.JMSMessageConsumerHandle.receive(JMSMessageConsumerHandle.java:445)
com.hbcbsnj.odmf.app.client.DocumentSearchManagerBean.receiveMessage(DocumentSearchManagerBean.java:209)
com.hbcbsnj.odmf.app.client.DocumentSearchManagerBean.sendReceive(DocumentSearchManagerBean.java:143)

Code of send method :

private String sendMessage(QueueSession session, String requestMessageString) throws Exception {
QueueSender sender = null;
Queue queue = null;
InitialContext initialContext = new InitialContext();
try {

queue = (Queue) initialContext.lookup(ApplicationProperties.EOB_REQUEST_Q);
sender = session.createSender(queue);
sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
TextMessage message = session.createTextMessage();
message.setJMSMessageID(MESSAGE_ID);
message.setText(requestMessageString);
sender.send(message);
String messageID = message.getJMSMessageID();
return messageID;
} catch (JMSException e) {
throw e;
} finally {
if (sender != null) {
sender.close();
}
}
}

code of receive method :

private String receiveMessage(QueueSession session, String messageSelector) throws Exception {
QueueReceiver receiver = null;
InitialContext initialContext = new InitialContext();
Queue queue = null;
try {

messageSelector = new StringBuffer().append("JMSCorrelationID = \'").append(messageSelector).append("\'").toString();
queue = (Queue) initialContext.lookup(ODMFApplicationProperties.EOB_REQUEST_Q);
receiver = session.createReceiver(queue, messageSelector);
TextMessage msg = (TextMessage) receiver.receive(); // Getting time out exception here
String returnString = msg.getText();
return returnString;

}catch (JMSException e) {
throw e;
} finally {
if (receiver != null) {
receiver.close();
}
}
}
 
Ranch Hand
Posts: 66
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to the JavaDoc, QueueReciever.receive() is a blocking call and there is no mention of a time out in the API. Even the one that takes a timeout duration (receive (long timeoutMillis) ) doesn't throw an exception. I do see the socket being opened for reading something. Does this occur for every message that is being produced? Can you see on the MQ side what's going on? Did the message come in to the JMS provider? Was the message completely lost or is it still on the queue when this exception occurred? (I'd say it's the latter, since it aborted without acknowledging the message).

Can you write a simple stand-alone java class which produces and consumes from the same MQ without any errors?
 
Pournima Shinde
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prabaharan,

I have tried with (receive (long timeoutMillis) ) by giving 50 sec timeout,though my query in MDB is taking only 15 sec to generate response but after increasing time out also no success,even I tried with Thread.sleep,but no way.And yes this is occurring for every message that we put on MQ. On MQ side yes we can see message which is present in request queue.Message was not lost when exception occurs. Also,we tried to send and receive message by creating sample project but getting same error. Don't know what is the issue?


Background:
We are migrating from WAS 5.0 to WAS 8 and EJB 2.0 to EJB 3.0.
We are also using Websphere MQ series for sending and receiving messages asynchronously. We have a specific search functionality in our application which works as below:

1. Click on search button ->
2. It calls struts 1.1 action class ->
3. It calls a stateless session bean - DocumentSearchManagerBean (Migrated to 3.0) -> then it prepares an request xml and calls a method named sendReceive(), this method first calls send() method which sends the message by putting request xml on MQ "REQUEST" queue then there is an MDB for which we defined activation specification and code in this MDB is called up whenever message appears on "REQUEST" queue. MDB calls another session bean there by DAO layer class to hit DB and generate response xml. This response xml is put on a MQ "RESPONSE" queue.
In order to listen to response xml there is a receive method written in DocumentSearchManagerBean which listens to "RESPONSE" queue and gets the response XML and parses that xml and throws out put to UI layer.

Things are working fine when we use EJB 2.0 with migrated WAS 8.0 code.
But when we work with EJB 3.0, it does not seems to be working. here MDB itself is not getting hit.
But as soon as we comment out receive method's code then MDB is getting hit.
Also whenever we manually put the message on MQ "REQUEST" queue then MDB is getting hit.



FYI:

private String sendReceive(String requestMessage) throws Exception {
String returnString = null;
QueueSession session = null;
QueueConnectionFactory connectionFactory = null;

try {
if (connection == null) {
InitialContext initialContext = new InitialContext();
connectionFactory = (QueueConnectionFactory) initialContext.lookup("jms/MQSAMPLE");
connection = connectionFactory.createQueueConnection();
}
try {
connection.start();
} catch (Exception e) {
e.printStackTrace();
}

session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

String messageSelector = sendMessage(session, requestMessage);
returnString = receiveMessage(session, messageSelector);
}
catch (JMSException ex) {
ex.printStackTrace();
throw ex;
} catch (NamingException ne) {
ne.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (session != null) {
session.close();
}
}
return returnString;
}

 
Prabaharan Gopalan
Ranch Hand
Posts: 66
VI Editor Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what I have understood so far: you have two queues. You try to put a message to your 'Request' queue. You have an MDB listening on the queue. And the MDB is not getting the message. If it gets the message, it will query the DB and create another message to be put on the 'Response' queue.

What I don't understand is why would you have this code:


And where exactly does the MDB figure in this design?
 
Pournima Shinde
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

We have tried today to send message to MQ through servlet and we are receiving message in the same servlet by QueueReceiver.receive() .We are succeeded in sending and receiving message in MQ by using servlet. Bu the same thing when we are trying by using session bean then it is hanging out for some time and getting time out exception.
As our session bean sends message in request queue then MDB heats,in this case is there any binding needed between session bean and MDB?
Asking because when servlet sends message in request queue then MDB heats successfully and QueueReceiver.receive() method in servlet got responce message in MQ.
Please advice.

Code for MDB:
package mq;



import javax.ejb.ActivationConfigProperty;

import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
import javax.naming.NamingException;



/**
* Bean implementation class for Enterprise Bean: EOBServiceProvider
*/

@MessageDriven(mappedName="EOBServiceProviderBean",
activationConfig = { @ActivationConfigProperty(
propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
// @ActivationConfigProperty(propertyName="destination", propertyValue="jms/QL.DEV.ODMF.EOB.REQ"),
// @ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue="Auto-acknowledge"),
// @ActivationConfigProperty(propertyName="subscriptionDurability", propertyValue="Durable")
})
public class EOBServiceProviderBean implements javax.jms.MessageListener {


/**
* onMessage
*/
public void onMessage(javax.jms.Message msg) {
System.out.println("EOBServiceProviderBean.onMessage()");

try {

TextMessage txtMsg = null;
if (msg instanceof TextMessage) {
txtMsg = (TextMessage) msg;
}

String eobRequestXML = txtMsg.getText();
System.out.println("eobRequestXML : "+eobRequestXML);
senMsg(txtMsg);

} catch (Exception e) {

e.printStackTrace();
// Log this exception and return a code -1
}
}

private void senMsg(TextMessage msg){

System.out.println("EOBServiceProviderBean.senMsg()");

InitialContext initialContext=null;
Queue resQueue =null;
QueueConnectionFactory queueConnectionFactory=null;
QueueConnection queueConnection = null;
QueueSender sender=null;
QueueSession queueSession =null;
try {
initialContext = new InitialContext();
queueConnectionFactory = (QueueConnectionFactory) initialContext.lookup("jms/MQDEVEOBQCF");

System.out.println("msg sent in MDB : "+msg.getText());
queueConnection = queueConnectionFactory.createQueueConnection();
queueConnection.start();
queueSession = queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
resQueue = (Queue) initialContext.lookup("jms/QR.DEV.ODMF.EOB.RES");
sender = queueSession.createSender(resQueue);

System.out.println("in MDB : Before sender.send...");

sender.send(msg);

System.out.println("in MDB : After sender.send...");
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}


Code for Session Bean:

package mq;



import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.text.StringCharacterIterator;

import javax.ejb.Stateless;
import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.xml.rpc.ServiceException;
import javax.xml.soap.SOAPElement;

import org.xml.sax.SAXParseException;


/**
* Bean implementation class for Enterprise Bean: DocumentSearchManager
*/
@Stateless
public class DocumentSearchManagerBean implements DocumentManager{

private QueueConnection connection = null;



@Override
public String findEOB(String eobRequestXML) {
String eobResponseXML = null;


try {
System.out.println("DocumentSearchManagerBean.findEOB()");
eobResponseXML = sendReceive(eobRequestXML);
} catch (Exception e) {
e.printStackTrace();

}
//return ODMFUtils.parseResponseXML(eobResponseXML);
return eobResponseXML;
}



private String sendReceive(String requestMessage, boolean eob) throws Exception {
System.out.println("requestMessage : " + requestMessage);
String returnString = null;
QueueSession session = null;

QueueConnectionFactory connectionFactory = null;

System.out.println("DocumentSearchManagerBean.sendReceive()");

try {
if (connection == null) {
InitialContext initialContext = new InitialContext();
connectionFactory = (QueueConnectionFactory) initialContext.lookup("jms/MQDEVEOBQCF");
connection = connectionFactory.createQueueConnection();
}
try {
connection.start();
} catch (Exception e) {
e.printStackTrace();
}



session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
System.out.println("Before send....");
sendMessage(session, requestMessage, eob);
System.out.println("After send...");

returnString = receiveMessage(session);
System.out.println("returnString : " + returnString);

}
catch (JMSException ex) {
throw ex;
} catch (NamingException ne) {
} catch (Exception ex) {
} finally {
if (session != null) {
session.close();
}
}
return returnString;
}

private voidsendMessage(QueueSession session, String messageString) throws Exception {
QueueSender sender = null;
Queue queue = null;
InitialContext initialContext = new InitialContext();
try {

// senderQueue = (Queue) getObjectByJNDILookup(QUEUE_SENDER_JNDI_NAME, false);
if (eob) {
queue = (Queue) initialContext.lookup("jms/QL.DEV.ODMF.EOB.REQ");
}
sender = session.createSender(queue);
sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
TextMessage message = session.createTextMessage();

message.setText(messageString);
sender.send(message);




} catch (JMSException e) {
throw e;
} finally {
if (sender != null) {
sender.close();
}
}
}

private String receiveMessage(QueueSession session) throws Exception {
QueueReceiver receiver = null;
InitialContext initialContext = new InitialContext();
Queue queue = null;
System.out.println("DocumentSearchManagerBean.receiveMessage()");
try {
if (eob) {
queue = (Queue) initialContext.lookup("jms/QR.DEV.ODMF.EOB.RES");

}
receiver = session.createReceiver(queue);

System.out.println("Before receive...");
TextMessage msg = (TextMessage) receiver.receive();
System.out.println("After receive...");
String returnString = msg.getText();

return returnString;
}catch (JMSException e) {
throw e;
} finally {
if (receiver != null) {
receiver.close();
}
}
}





}
 
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic