Windows 工作流:“单例”式工作流?
我有一个工作流程,它将监视某些数据库并在注意到触发器时启动其他工作流程。 我只希望这个“观察者”工作流程的一个实例在任何时间点运行; 否则,如果两个或多个正在运行,它们都会注意到更改,并且都会启动相同的工作流程,这将无法正常工作。
此“观察者”工作流程将持续存在。 那么...我该如何做到这一点,以便如果运行时还没有保存此工作流的实例,它会启动一个实例,但如果已经存在,则只需使用保存的实例?
听起来我几乎可以创建一个小型的运行一次控制台应用程序来启动我想要的工作流程,然后“真正的”运行时只是拉出持久的工作流程,并且从不尝试创建新的工作流程,但这听起来不太优雅。
I have a workflow that will watch certain databases and kick off other workflows when it notices a trigger. I only want one instance of this "observer" workflow to be going at any point in time; otherwise, if two or more were running, they'd both notice the change and both fire off the same workflow, which wouldn't work well.
This "observer" workflow is persisted. So...how do I make it so that if the runtime doesn't have an instance of this workflow persisted already, it starts one, but if one is already there, just use the persisted one?
Almost sounds like I could create a small run-once console app that kicked off the workflow I wanted, and then the "real" runtime just pulled the persisted one and never tries to create a new one, but that doesn't sound very elegant.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我正在为我目前正在进行的一个项目考虑这个问题。 然而,在我看来,监视数据库的功能不是工作流程的职责。
我们将创建一个服务来添加到运行时。 该服务将引发工作流在 HandleEventActivity 中侦听的事件。 这样,工作流程就会闲置、持久并保持这种状态,直到真正需要执行实际工作为止。
I'm considering this problem as well for a project I'm currently working. However it seems to me that the function of monitoring the DB is not the responsibilty of the workflow.
We're going to create a Service to add to the runtime. This service will raise events that the workflow listens for in the HandleEventActivity. That way the workflow goes idle, is persisted and stays that way until a real work actually needs doing.
前段时间我们在一个项目中遇到了这个问题。 我们提出的解决方案是托管两个运行时; 一种有持久性服务,一种没有。 在没有持久性服务的运行时中,我们运行了几个这种“监视工作流程”,这些工作流程在主机启动时自动启动。
这就是它的实现方式:
首先,我们有一个配置文件,在其中设置持久性服务:
在工作流主机应用程序中(剪切和编辑,但我想我传达了这个想法):
We had this problem in a project a while ago. The solution we came up with was to host two runtimes; one with persistence services and one without. In the runtime with no persistence service we were running a couple of this kind of "monitoring workflows" that were automatically started when the host was started.
This is how it was implemented:
First, we had a config file in which we set up the persistence service:
And in the workflow host application (cut and edited, but I think i communicates the idea):