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 » Temporary queue problem time out before recieving the messag

Post new topic  Reply to topic
 Temporary queue problem time out before recieving the messag « View previous topic :: View next topic » 
Author Message
usman.usmani@gmail.com
PostPosted: Sat Sep 16, 2006 3:54 am    Post subject: Temporary queue problem time out before recieving the messag Reply with quote

Newbie

Joined: 20 Jun 2006
Posts: 8

Hi,

I am using WAS 6.0.2.11. I am using default messages to communicate
between applications. I need to communicate synchronously between two
services/application deployed A and B. when i am sending a message from
A to B to the destination B listens to I create a temporary queue and
from A and set it as JMSReplyTo destination send it to B. B sends me
message successfully where as A times out imediately after I send the
message irrespective of the timeout i specify although i am listening message using the following code. Can
any one tell me the solution or workarround.


Following is the code that I use at A.


InitialContext context = null;
try {
context = new InitialContext();
ConnectionFactory factory = (ConnectionFactory)
context.lookup("jms/QCFMQGateWay");
Destination destination = (Destination)
context.lookup("jms/MQGWQueue");
Connection connection = factory.createConnection();
Session session =
connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination);
Destination replyQueue = session.createTemporaryQueue();
BytesMessage message = session.createBytesMessage();
message.setJMSReplyTo(replyQueue);
MessageConsumer replyConsumer = session.createConsumer(replyQueue);
byte [] bytes =
ObjectSerializer.serializeObject(transferObjectBase);
message.writeBytes(bytes);
producer.send(message);


System.out.println("=======================================================­====");
System.out.println("The connection state is " + connection);
System.out.println("Listening on temporary destination = " +
replyQueue);
System.out.println("=======================================================­====");
connection.start();
BytesMessage msg = (BytesMessage)replyConsumer.receive(60000);
System.out.println("=======================================================­====");
System.out.println("The connection state is " + connection);
System.out.println("Message revieved from replyQueue = " + msg);
System.out.println("=======================================================­====");
if(msg!=null)
{
String reply = getBodyAsString(msg);
System.out.println("The confirmation reply message is " + msg);
if(reply == null || reply.trim().equals(""))
throw new CommunicationException("Unidentified confiramtion reply
format");
else if(reply.equals("Failed"))
throw new CommunicationException("Failed to send request. Please
check the logs");


}else
throw new CommunicationException("Failed to recieve confirmation
message from gateway");


} catch (NamingException e) {


throw new CommunicationException("Cannot find initial Context" ,e);
} catch (JMSException e) {


throw new CommunicationException("Error Occured",e);
} catch (IOException e) {
throw new CommunicationException("cannot serialize object",e);
}


Following is the code at service B that sends a sync response


Destination dest = msg.getJMSReplyTo();


if (dest!=null){


log.debug("reply
destination is :"+dest);


InitialContext ctx = new
InitialContext();


/****


*


* specify the connection factory
name


*/


QueueConnectionFactory factory =
(QueueConnectionFactory)ctx.lookup("jms/QCFMQGateWay");


// create a connection and session


Connection connection =
factory.createQueueConnection();


log.debug("connection in MQGateway
is "+connection);


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


MessageProducer producer =
session.createProducer(dest);


BytesMessage byteReplyMsg =
session.createBytesMessage();


byteReplyMsg.writeBytes(replymsg.getBytes());


producer.send(msg);


log.debug("the reply message has
been sent to :"+dest);


}else {


/// to do send to a
specified destination for errors


log.debug("destination
is null ---- not going to send");


}
_________________
Usmani
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Sat Sep 16, 2006 4:49 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I don't understand what JMS provider you are using. You say "default messages" and then you say "temporary queue".

Also, am I correct that you are trying to both send a request and receive a reply inside the same transaction? How will the request ever get committed?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
usman.usmani@gmail.com
PostPosted: Sat Sep 16, 2006 6:26 am    Post subject: Reply with quote

Newbie

Joined: 20 Jun 2006
Posts: 8

I am sorry for not being clear first time. I am using Default messaging inside by creating a bus and destinations over the bus. I have deployed 2 applications A and B where B listens to a destination. A wants to communicate with B. A creates a temporary queue and sets it as JMSReplyTo in the message it sends and than sends the message to B and starts listening on the temp queue. B does some processing which takes only a few milliseconds i.e. less than time out for a and sends a message to A on the same reply to destination it recieved. now A is not revcieving the reply.

I hope the problem is clearified I cannot understand by transaction what are you reffering to. If you can help I shall stand grateful.
_________________
Usmani
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Sat Sep 16, 2006 7:39 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Messages being SENT in a transaction are not SENT until the Transaction is committed.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
usman.usmani@gmail.com
PostPosted: Wed Sep 20, 2006 12:40 am    Post subject: Reply with quote

Newbie

Joined: 20 Jun 2006
Posts: 8

Found the solution after getting the connection you have to start the connection by connection.start() dont understand pretty much why but this is the way it works
_________________
Usmani
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 » Temporary queue problem time out before recieving the messag
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.