Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Timeout for JMS Receiver.

 
pankaj eklar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to write code for following requirement:

1. I want to send a request message on one queue say Q1.
2. I should keep checking for response to the earlier request on another topic say T1, for next 2 mins.
3. If I dont receive a response on T1 within 2 mins I stop waiting for the response and continue.

There can be more than one instances which will put a message on Q1 and connect to T1 to wait for the response.

Now the real problem that I am facing is where do I write the code for counting two min timeout?

Any suggestions?

Thanks,
Pankaj
 
Sandip Sarkar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi pankaj,


You can listen for the response from the topic T1 in the onMessage method. You can use a Timer by implementing the TimedObject interface and can wait for a timeout of 2 mins in the same method.

If i don't get a response that is to say my onMessage doesn't gets called in 2 mins...my timer expires and i don't need to wait.

Hope this helps.

Thanks,
Sandip
 
pankaj eklar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sandip,

Thanks for the quick reply. I noticed that TimedObject is not supported by Weblogic 8.1 sp5 (supported from weblogic 9.0 onwards). Please correct me if I am wrong about this. So I will not be able to use TimedObject.

If there is any other way to implement this?

Thanks,
Pankaj.
 
Sandip Sarkar
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pankaj,

The classes for EJB Timer Bean(TimedObject.class) are missing in their J2EE-Jar for Weblogic 8.1.

You can try by putting the TimedObject jar file in application classpath. But i am not sure if this works.

Thanks,
Sandip

 
pankaj eklar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sandip,

I am doing this change for one of the clients and I cant assume that they will have this jar file

Thanks,
Pankaj
 
pankaj eklar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any inputs?

Thanks,
Pankaj
 
pankaj eklar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have implemented this Using NotificationListener interface. But there is one more problem that I am facing. I will post it in a different thread. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic