This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes problem JMS request reply pattern in CMT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "problem JMS request reply pattern in CMT" Watch "problem JMS request reply pattern in CMT" New topic

problem JMS request reply pattern in CMT

Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205
I have following code...My Stateless bean is CMT.When, I do the bean as BMT
,the following code works fine....I know there is Transaction concept in JMS request reply pattern. As when we send message that time we should commit the Transaction and while receiving the transaction again start new transaction...I did same in following code, but receive method never gets the thrwos the exception....

private String sendMessage(Serializable payload) {

Context ctx = new InitialContext(env);
conn = getJmsConnection(); orderQueue =
session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
ObjectMessage message = session.createObjectMessage();
replyQueue = session.createTemporaryQueue();
producer = session.createProducer(orderQueue);

System.out.println("Request Has been Sent");
actionResult= receiveMessage(replyQueue);
}catch(Exception e){

}finally {

return actionResult;

public String receiveMessage(Destination replyQueue ){

QueueSession session = null;

if(replyQueue == null){
System.out.println("I am null");

if (replyQueue != null) {
MessageConsumer replyConsumer = session.createConsumer(replyQueue);
javax.jms.Message responseMessage = replyConsumer.receive(10000L);
if (responseMessage != null) {
System.out.println("Response received");
} else {
System.out.println("Response not received due to timeout");

if (responseMessage instanceof TextMessage) {
TextMessage requestMessage = (TextMessage) responseMessage;
}catch(Exception e){

return "hello";
Gast�n Acevedo

Joined: Dec 08, 2008
Posts: 1
Im very new to jms but...
The requires new transaction in the method for receive the reply only works if you obtain a new reference to the bean, not only when you call the method in the same instance.

maybe this can help
Consider Paul's rocket mass heater.
subject: problem JMS request reply pattern in CMT
Similar Threads
JMS Request/Reply mode
problem while reading message from reply queue using JMSCorrelationID
Recieving response from MDB
Exception in MDB
TimeOut in sending and receiving message in MQ5.3 thorugh RAD 8