开发者

Daemon in Java: simple schedule application?

This app must perform connection to a web service, grab data, save it in the database. Every hour 24/7. What's the most eff开发者_运维问答ective way to create such an app in java?

How should it be run - as a system application or as a web application?


Keep it simple: use cron (or task scheduler)

If that's all what you want to do, namely to probe some web service once an hour, do it as a console app and run it with cron.

An app that starts and stops every hour

  • cannot leak resources
  • cannot hang (may be you lose one cycle)
  • consumes 0 resources 99% of the time


look at quartz, its a scheduling library in java. they have sample code to get you started. you'd need that and the JDBC driver to your database of choice. no web container required - this can be easily done using a stand alone application


Try the ScheduledExecutorService.


Why not use cron to start the Java application every hour? No need to soak up server resources keeping the Java application active if it's not doing anything the rest of the time, just start it when needed,


If you are intent on doing it in java a simple Timer would be more than sufficient.


Create a web page and schedule its execution with one of many online scheduling services. The majority of them are free, very simple to use and very reliable. Some allows you to create schedules of any complexity just like in cron, SqlServer job UI, etc. Saves you a LOT of headache creating/debugging/maintaining your own scheduling engine, even if it's based on some framework like Ncron, Quartz, etc. I'm speaking from my own experience.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜