Which layer should scheduled task be put?

痞子三分冷 提交于 2019-12-08 05:13:12

问题


I'm trying to implement DDD application with layered architecture. I have:

  • Infrastructure layer - a layer which implements technology specific parts of the application.
  • Domain layer - a layer which contains domain model.
  • Application layer - a layer which contains interferences to interact with domain model.
  • And interfaces layer - a layer which receives events from the outside.

The classic 3 layer (+ infrastructure) architecture is quite clear. But my application isn't very classic. Beside UI I have scheduled task which should be ran periodically. I thought about putting such tasks into interfaces layer, because these task actually handle events like UI. But there is a problem, I can't make decision which layer I should put an scheduler which fire events for scheduled tasks.

I draw a sketch

Which layer should I put the scheduler object? Or may be where is another way to design application with internal event generator.


回答1:


To me, scheduler is a host for task executor (in the same way as your JSP container is a host for you UI). I would model it as an external entity and implement it as another infrastructure project.



来源:https://stackoverflow.com/questions/3912823/which-layer-should-scheduled-task-be-put

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