在.NET中实现worker服务
我需要向我当前的解决方案添加一个“工作进程”,并满足以下要求:
- 必须连续运行(或以特定的时间间隔)
- 自动启动
- 从多个源(SQL 数据库、WCF 服务等)获取数据并进行一系列操作计算
- 根据这些结果做出决策并执行一些操作(保留一些结果、发送通知……)
- 它应该具有公共服务操作以允许交互(例如,请求重新处理特定日期的数据)
我将其创建为.NET 类库,因此我可以利用解决方案中的其他程序集。
它将部署在企业环境中,我可以完全访问服务器。
您会选择哪种托管选项?
- Windows 服务
- IIS 中的 WCF 服务与 Windows Server AppFabric(允许自动启动)
- 其他选项?
I need to add a "worker process" to my current solution with the following requirements:
- must run continuously (or at specific intervals)
- auto start
- get data from several sources (SQL database, WCF services,...) and make a series of calculations
- make decisions based on those results and perform some actions (persist some results, send notifications,...)
- it should have public service operations to allow interaction (request to reprocess data from a particular day, for instance)
I will create it as a .NET class library, so I can take advantage of the other assemblies in my solution.
It will be deployed in an enterprise environment and I have total access to the servers.
What hosting option would you take?
- Windows Service
- WCF Service in IIS with Windows Server AppFabric (allows auto start)
- Other option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了几乎完全相同的问题,我选择了一个以编程方式启动 WCF 服务的 Windows 服务,以便它可以与我的主应用程序进行通信,并且它运行得很好。我什至添加了额外的逻辑。我可以设计我的worker的任务并在我的worker上使用MEF加载它们,这样worker甚至不知道执行什么,他只是用参数启动任务,检索状态信息,并返回执行结果。
I had almost the exact same problem, I chose a Windows Service that programatically launched a WCF Service so it could communicate with my main application, and it's working pretty good. I even added extra logic. I could design my worker's tasks and load them with MEF on my worker, so the worker didn't even know what executes, he just launches tasks with parameters, and retrieves status information, and returns execution results.
这是我在 Windows 服务中托管的 WCF 应用程序。它提供了您需要的所有功能以及使用 wmi 进行远程管理和监控。
This is a wcf app hosted in a windows service to me. It provides all of the functionality you need plus remote management and monitoring with wmi.