Solved

Writting a timeout for jms

Posted on 2004-09-30
5
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 125 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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

628 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