IIS 中托管的 WCF 服务中的周期性任务 [英] Periodic tasks inside WCF service hosted in IIS

查看:29
本文介绍了IIS 中托管的 WCF 服务中的周期性任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望由 IIS 中托管的 WCF 服务执行一些定期操作.做这个的最好方式是什么?创建计时器看起来不是一个好的解决方案.创建一个像心跳一样运行的 Windows 服务看起来像是一个问题解决方案,但它仍然闻起来并不好.什么方法可以很好地解决这个问题?

We would like to have some periodic actions executed by our WCF service hosted in IIS. What is the best way to do this? Creating a timer doesn't look as a good solution. Creating a windows service that would behave as some kind of a heart beat looks like a problem solution, but it still doesn't smell good. What approach will be a good solution to this problem?

推荐答案

这取决于您要执行的操作.如果是与数据库相关的清理操作,例如删除孤立的购物车,您可以在您选择的数据库中为此安排一个作业,例如 SQL Server 非常可靠的作业引擎.如果 Windows 服务是基于操作系统的操作,例如定期清理/删除文件等,那么它是一个很好的候选者.由于 IIS/WCF 服务通常被设计为更多地处理外部响应,因此我认为使用它不会是错误的用于您的任务的操作系统或数据库的服务层.

That depends on what your action is trying to do. If it's a database related clean up action, e.g. deleting orphaned shopping carts, you could schedule a job for this in your database of choice, like SQL Server's very reliable job engine. A Windows service would be a great candidate if it's an OS based action like periodic clean up/deletion of files etc. Since an IIS/WCF service is usually designed more to handle external responses I don't think it'd be wrong to use the service layers of the OS or DB for your task.

这篇关于IIS 中托管的 WCF 服务中的周期性任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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