• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Should I Code A Daemon?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic