Handling exception logging in a Java task scheduler program?

别说谁变了你拦得住时间么 提交于 2019-12-12 02:14:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!