Solved

Writting a timeout for jms

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to determine if a string is a valid SHA value 7 57
Java: The Public Class Main 4 66
How to configure empty element in XML Document parser? 15 58
Session in java desktop 5 37
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

738 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