开发者

run one scheduler at a time

I have two beans which is running the scheduler

<bean id="eventService" class="xxx.xxxx.xxxxx.EventSchedulerImpl">
</bean>

<bean id="UpdateService" class="xxx.xxxx.xxxxx.UpdateSchedulerImpl">
</bean>

I want to make sure only one scheduler is running at time when EventSchedulerImpl is running UpdateSchedulerImpl should not run also implemented "StatefulJob" on both the schedul开发者_如何学Goer will that work? do i need to do more?

appericate your idea guys


One way would be to configure a special task executor so that it contains only one thread in its thread pool, and configure its queue capacity so that jobs can be kept "on-hold". So only one task can run at a time with this task executor, and the other task will get queued.

But I don't like this approach. Having a single-threaded task executor seems like a recipe for problems down the road.

What I would do is simply write a wrapper service that calls your target services in the order you need. Then schedule the wrapper service instead.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜