Scheduler実装サービス jp.ossc.nimbus.service.scheduler.TimerSchedulerService

jp.ossc.nimbus.service.scheduler.TimerSchedulerServiceは、java.util.Timerを使ってスケジュールを起動するScheduler実装サービスです。

このサービスは、複合的なサービスで、以下のサービスを下位サービスとして使用します。

下位サービスインタフェース用途
jp.ossc.nimbus.service.scheduler.Schedule実行するスケジュールとして使用する。
jp.ossc.nimbus.service.scheduler.ScheduleFactoryスケジュールを取得する。
jp.ossc.nimbus.service.scheduler.ScheduleStateManagerスケジュールの実行状態を保存する。

以下に簡単なサービス定義を示します。

  1. <?xml version="1.0" encoding="Shift_JIS"?>
  2. <!DOCTYPE server PUBLIC
  3. "-//Nimbus//DTD Nimbus 1.0//JA"
  4. "http://nimbus.sourceforge.jp/dtd/nimbus-service_1_0.dtd">
  5. <server>
  6. <manager>
  7. <!-- スケジューラサービス -->
  8. <service name="Scheduler"
  9. code="jp.ossc.nimbus.service.scheduler.TimerSchedulerService">
  10. <!-- スケジューラの起動時にスケジュールを開始するかどうかを設定する -->
  11. <attribute name="ScheduleOnStart">true</attribute>
  12. <!-- スケジュールサービスのサービス名を設定する -->
  13. <attribute name="ScheduleServiceNames">
  14. #Schedule1
  15. #Schedule2
  16. #Schedule3
  17. </attribute>
  18. <depends>Schedule1</depends>
  19. <depends>Schedule2</depends>
  20. <depends>Schedule3</depends>
  21. </service>
  22. <!-- スケジュール1
  23. スケジューラ起動の1秒後に1度だけ実行するスケジュール
  24. -->
  25. <service name="Schedule1"
  26. code="jp.ossc.nimbus.service.scheduler.TimerScheduleService">
  27. <attribute name="Name">Task1</attribute>
  28. <attribute name="Task">
  29. <object code="sample.task.SampleTask">
  30. <attribute name="Name">Task1</attribute>
  31. </object>
  32. </attribute>
  33. <attribute name="Delay">1000</attribute>
  34. </service>
  35. <!-- スケジュール2
  36. スケジューラ起動直後に実行され、1秒間隔で実行され続けるスケジュール
  37. -->
  38. <service name="Schedule2"
  39. code="jp.ossc.nimbus.service.scheduler.TimerScheduleService">
  40. <attribute name="Name">Task2</attribute>
  41. <attribute name="Task">
  42. <object code="sample.task.SampleTask">
  43. <attribute name="Name">Task2</attribute>
  44. </object>
  45. </attribute>
  46. <attribute name="Delay">0</attribute>
  47. <attribute name="Period">1000</attribute>
  48. </service>
  49. <!-- スケジュール3
  50. スケジューラ起動直後に実行され、1秒間隔で実行され続けるスケジュール
  51. 但し、タスクの処理時間が1.5秒かかるため、結果として1.5秒間隔で実行される。
  52. また、非同期処理用のキューを設定しているため、他のスケジュールの実行には影響を及ぼさない。
  53. -->
  54. <service name="Schedule3"
  55. code="jp.ossc.nimbus.service.scheduler.TimerScheduleService">
  56. <attribute name="Name">Task3</attribute>
  57. <attribute name="Task">
  58. <object code="sample.task.SampleTask">
  59. <attribute name="Name">Task3</attribute>
  60. <attribute name="ProcessTime">1500</attribute>
  61. </object>
  62. </attribute>
  63. <attribute name="Delay">0</attribute>
  64. <attribute name="Period">1000</attribute>
  65. <attribute name="QueueServiceName">Queue</attribute>
  66. <attribute name="DependsScheduleNames">Task1</attribute>
  67. <depends>
  68. <!-- 非同期処理用のキューサービス -->
  69. <service name="Queue"
  70. code="jp.ossc.nimbus.service.queue.DefaultQueueService"/>
  71. </depends>
  72. </service>
  73. </manager>
  74. </server>


スケジューラ/簡易スケジューラ/Scheduler