Solved

Writting a timeout for jms

Posted on 2004-09-30
5
169 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 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now