Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Should I Code A Daemon?

 
John Riool
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Looking for some advice. I need to develop a Java application to:
- Query a database looking for new requests (request_status == 'New')
- When a 'New' request is found, instantiate a request object and pass it the request_params
- Update the database (request_status = "Processing")
- Sleep for 5 seconds
- Start entire process over

I think what I am looking for is generally referred to as a daemon. I searched Google for some examples, but cannot find a simple one that I understand -- Kinda new at this.

So, my questions are:
- Am I looking at the best practice for doing this (query, sleep, query, sleep...)?
- Can you give me advice on the best practice?
- Can you point me to an example of the best practice?
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Riool wrote:
- Am I looking at the best practice for doing this (query, sleep, query, sleep...)?


Well, you said those were your requirements. So yes, that's what you have to do.

Or were you asking whether those requirements were a "best practice"? I suppose that would depend on what the actual problem was. If all we have is a set of requirements, with no information about what problem they are intended to solve, it's pretty hard to say whether they solve that problem in a good way.
 
John Riool
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

The program requirements would be:
- Look for new requests in a database
- When a new request is found, start another program that will generate a report

A couple of notes:
- A new request can show up in the database at any time
- I would like to begin processing new requests with 3-5 seconds of arrival
- More than one new request can be waiting in the database
- The report generating program can take over twenty minutes to complete

So I guess what I am really asking is how should I approach the design of the program?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic