问题
I need to design a Task Scheduler Where
1) User should be able to schedule multiple task at the same time.
2) There should be proper error handling on failure of any task and should not affect the other running tasks.
I found the related programme at http://www.roseindia.net/java/example/java/util/CertainAndRepeatTime.shtml
My concern is about handling of point 2 in program provided at above link. Say I schedule a recurring mail send process in above program which will be run first time on 12 september 2011 at 2 am, and will be repeated after every 2 hours Say a one process fais at 8 am. I want to log it in log file with task name and time details. Now if I look at above programme i.e CertainAndRepeatTime.java. This program will exit once it schedules all the tasks. Where and how should handle the logging?
回答1:
You should have a look at the Quartz scheduler.
回答2:
Definitely Quartz, as Thomas Jung already said. Check out Citrine, a web management layer on top of Quartz.
回答3:
You should handle it like every other thread. Some try-catch-logging in the run method of the TimerTask.
来源:https://stackoverflow.com/questions/7377204/handling-exception-logging-in-a-java-task-scheduler-program