定时任务应该放在哪一层?
我正在尝试使用分层架构来实现 DDD 应用程序。我有:
- 基础设施层 - 实现应用程序的技术特定部分的层。
- 领域层 - 包含领域模型的层。
- 应用层——包含与领域模型交互的干扰的层。
- 接口层——从外部接收事件的层。
经典的 3 层(+ 基础设施)架构非常清晰。但我的应用程序不是很经典。除了 UI 之外,我还安排了应定期运行的任务。我考虑过将此类任务放入接口层,因为这些任务实际上处理类似 UI 的事件。但有一个问题,我无法决定应该在哪一层放置调度程序来触发计划任务的事件。
我画了一个草图
我应该将调度程序对象放在哪一层?或者可能是使用内部事件生成器设计应用程序的另一种方法。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对我来说,调度程序是任务执行器的主机(就像 JSP 容器是 UI 的主机一样)。我将其建模为外部实体,并将其实现为另一个基础设施项目。
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.