Solved

Writting a timeout for jms

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Application launch issue with Apache Tomcat 5 44
even odd program using while loop 3 40
servlet example issue 6 39
hibernate insert example 13 29
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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

772 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