Windows 激活服务中的单例模式
我有一些 WCF 服务目前正在一个非常基本的 NT 服务中自行托管。我想扩展我的应用程序以添加 WCF 服务的配置、更新以及隔离(我希望每个 WCF 服务位于其自己的 AppDomain 中)。这些 WCF 服务包含需要定期运行的逻辑、ping 数据库以及从外部设备获取信息,以便在收到请求时可以随时获取数据。
我正在考虑尝试 Windows 激活服务,因为我真的很喜欢托管服务基础设施附带的配置和隔离。如果我不使用 WAS,我基本上必须自己编写相同的代码。
据我了解,虽然 WAS 并不真正支持在有人实际调用服务上的方法之前运行服务的模型。我在这里读到的文章
指出“这本质上意味着开箱即用的 WAS 托管并不真正适合会话或单例服务,它更适合无状态的每次调用服务。”
它确实说“开箱即用”,所以我想知道是否有人使用 WAS 来托管 WCF 服务,该服务的行为实际上更像 NT 服务(独立于调用它的方法来启动和停止)。 或者任何其他想法都会很棒。我计划自己编写这个基础设施,在自定义 ServiceHost 中托管 WCF 服务,并将它们的执行放在单独的 AppDomain 中,并允许在初始安装和更新后提供这些服务。但是,如果不需要的话,我宁愿不拥有该代码。
谢谢
约书亚
I have a few WCF services that are currently being self hosted, in a very basic NT Service. I want to expand my application to add provisioning of WCF Services, and updates, as well as isolation (I want each WCF Service to be in its own AppDomain). These WCF Services contain logic that needs to be run on a regular basis, pinging the database, and getting information from external devices so that when a request comes in the data is readily available.
I'm thinking about trying out Windows Activation Service, because i really like the provisioning, and isolation that comes with a managed services infrastructure. If I didn't use WAS I would essentially have to write the same code myself.
From what I understand though WAS does not really support the model of having a service that is running before someone actually calls a method on the service. the article I read here
states "That means in essence that out-of-the-box WAS hosting is not something that is really suited for sessionful or singleton services. It is more suitable for stateless per-call services."
it does say that "Out of the box" so I'm wondering if anyone has used WAS to host a WCF service that really behaves more like an NT Service (starting and stopping independantly of having a method called upon it).
Or any other ideas would be great. I was planning on writting this infrastructure myself, to host WCF services in a custom ServiceHost, and put their execution in a seporate AppDomain, as well as allow for provision of these services after initial installation, along with updates. However, I would MUCH MUCH MUCH rather not own that code if I don't have to.
thanks
Joshua
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想使用 WAS,那么支持您的服务的正确 Singleton 实例将会很棘手。
这听起来像是谎言,您真正需要做的是创建计划任务。您可以根据计划任务每 5 分钟运行一次数据库更新实用程序,而不必担心单例。
If you want to use WAS, it will be tricky to support a proper Singleton instance of your service.
It sounds lie what you really need to do is create a scheduled task. You could run your database update utility every 5 minutes from a scheduled task and should not have to sweat the singleton.