Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Writting a timeout for jms

Posted on 2004-09-30
5
Medium Priority
?
197 Views
Last Modified: 2010-03-31
Hey everyone,
  Well I have another pretty easy question that I am kind of not sure about.  I am trying to figure out how to write a timeout for a jms message.  I basically send a message to the server and the server sends a message back, however if the message is not sent back the client side just sits and waits.  I would like to place a timeout so after 30 seconds or so if a message is not recieved then it will stop waiting.  I have never written a timeout and cant really find much good documentation on it.  Can anyone kind of steer me in the right direction here?

Thanks again for all your help!
0
Comment
Question by:kassidy2010
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Giant2
ID: 12191756
You could use the Timer.
http://www.javaalmanac.com/egs/java.util/ScheduleLater.html
You can schedule a timer before you send and wait.
When this timer is gone, then then block the wait in the send class.

Hope this could help you.
Bye, Giant.
0
 
LVL 9

Accepted Solution

by:
DrWarezz earned 375 total points
ID: 12194079
OR, you COULD try this:

-Create a thread to listen for the message  (which will set a boolean variable as true if a message has been recieved)
-Start the thread
-pause for 30 seconds  (ie;   try{Thread.sleep(30 *1000);} catch (Exception e) {}    )
-then check if the boolean var is 'true'. If not, close the socket, etc..

If you can make some sence of that, then you could get it to work :P

Best of luck,
[r.D]
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12197518
In JMS
its accually the time of the Publisher you set
I did something like this

publisher = this.createTopicPublisher(session, topic);
            //So that the messages dies after 6 seconds
publisher.setTimeToLive(message.getTimeout());
0
 
LVL 12

Expert Comment

by:Giant2
ID: 12197523
armoghan,
kassidy2010 not specify is he/she use JMS.
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 12257985
8-) Thank you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This video teaches viewers about errors in exception handling.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question