计划任务应放在哪一层? [英] Which layer should scheduled task be put?

查看:99
本文介绍了计划任务应放在哪一层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用分层体系结构来实现DDD应用程序.我有:

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

  • 基础结构层-实现应用程序中技术特定部分的层.
  • 域层-包含域模型的层.
  • 应用层-包含与领域模型进行交互的干扰的层.
  • 与接口层-从外部接收事件的层.

经典的3层(+基础结构)体系结构非常清晰.但是我的应用程序不是很经典.除了UI,我还安排了应定期运行的任务.我考虑过将此类任务放入接口层,因为这些任务实际上处理的是诸如UI之类的事件.但是有一个问题,我无法决定应该放置哪个调度程序来触发计划任务的事件.

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.

我画草图

应该将调度程序对象放在哪一层?或者可能是使用内部事件生成器设计应用程序的另一种方式.

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

推荐答案

对我来说,调度程序是任务执行程序的宿主(与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.

这篇关于计划任务应放在哪一层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆