java - 怎样设计动态调度系统
PHP中文网
PHP中文网 2017-04-17 11:05:17
0
1
402

最近工作上需要设计一个动态调度系统,当然不是在spring中配置固定执行的CronJob。这些任务需要做持久化,当服务器正常或者非正常关闭时任务都不会丢。看到Sonartype Nexus中的任务控制是比较完整的,但是没有源码看不到怎样实现的。

应用场景1:用户可以在界面上定制一个提醒,当时间到了会发送邮件。用户还可以修个这个提醒的触发时间。

应用场景2:每天晚上定时生成订单信息,发送到指定服务器。但是有时候可能需要提前进行完成这个任务。所以可以手工执行某个任务。

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
左手右手慢动作

Persistence and the dynamic scheduling system you mentioned are two concepts. The best way to implement your thing is:

Use AOP to achieve persistence, intercept all function operations, and then persist the results of all operations.

Application scenario 1: Users can customize a reminder on the interface, and an email will be sent when the time is up. Users can also modify the triggering time of this reminder.

This implementation mechanism is: Create a task pool, then save the task information, and then use ExecutorService to schedule the operation. Then use this function to intercept the semaphore when the server exits, and persist the task at this time.

Runtime.getRuntime().addShutdownHook(new xxxThread());

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template