Sql工作流持久化服务不保存工作流状态

发布于 2024-07-15 10:41:43 字数 1166 浏览 5 评论 0原文

大家好,

我正在处理一个非常奇怪的情况。 我开发了一个状态机工作流程,直到今天它都运行良好。 现在,Sql Workflow Persistence Service 不保存工作流状态。 没有任何例外,只是它不保存状态。 流程正常进行到事件驱动活动,即按照本文链接,必须保存工作流状态的条件之一(它之前一直做得很好)。

Sql Workflow Persistence Service 的配置如下所示:

     <workflowRuntime name="WorkfolwServiceHostRuntime" validateOnCreate="true"
        enablePerformanceCounters="true">
        <services>
          <add 
            type="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, 
                System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, 
                PublicKeyToken=31bf3856ad364e35" 
             connectionString="Data Source=svr; 
               Initial Catalog=WorkflowPersistence; user id=User;password=Pass; 
               Trusted_Connection=False" LoadIntervalSeconds="1" 
               UnLoadOnIdle="true"/>
          
        </services>
      </workflowRuntime>

也许问题是因为还有一个应用程序托管工作流运行时并使用相同的工作流持久性数据库。 我找不到任何信息是否允许这样做。

我看不出发生这种情况的任何其他原因,所以我将不胜感激任何建议。

谢谢

Hallo everybody,

I'm dealing with a pretty strange situation here. I have developed a State Machine Workflow and it worked just fine until today.
Now, the Sql Workflow Persistence Service does not save the workflow state. There is no any exception, just it does not save the state. The flow is going normally to the Event Driven activity which is, by following this article link, one of the conditions when workflow state has to be saved (what it has been doing just fine before).

The configuration of Sql Workflow Persistence Service look like this:

     <workflowRuntime name="WorkfolwServiceHostRuntime" validateOnCreate="true"
        enablePerformanceCounters="true">
        <services>
          <add 
            type="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, 
                System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, 
                PublicKeyToken=31bf3856ad364e35" 
             connectionString="Data Source=svr; 
               Initial Catalog=WorkflowPersistence; user id=User;password=Pass; 
               Trusted_Connection=False" LoadIntervalSeconds="1" 
               UnLoadOnIdle="true"/>
          
        </services>
      </workflowRuntime>

Maybe the problem is because there is one more application that hosts workflow runtime and uses the same workflow persistence database. I couldn't find any information if this is allowed or not.

I cant see any other reason why is this happening, so I will appreciate any suggestion.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

乖乖公主 2024-07-22 10:41:43

通常,工作流在空闲时会被保留。 持久化的时间还取决于轮询间隔等因素(您在创建 SQLPersistenceService 并将其附加到运行时时提供的间隔)。此外,工作流使用的所有内容,尤其是。 ExternalDataEvent 参数和事件应标记为Serialized

关于处理异常,您应该将FaultHandlersActivity添加到工作流程中,捕获的异常将保存在与FaultHandlersActivity一起公开的Fault属性中。

希望这有帮助。

Normally the workflow is persisted when it becomes idle. How soon it gets persisted also depends upon factors such as the polling interval ( which you would have provided while creating the SQLPersistenceService and attaching it to the runtime.) Also Everything that the workflow uses, esp. The ExternalDataEvent args and the events should be marked as Serializable.

Regarding handling Exceptions, you should add FaultHandlersActivity to your workflow, and the exception that is caught, will be saved in the Fault property that gets exposed along with the FaultHandlersActivity.

Hope that's helpful.

南…巷孤猫 2024-07-22 10:41:43

好吧,终于我知道问题出在哪里了。
在第一篇文章中,我写道,起初一切都正常工作,但经过一些小更改后,这不会影响工作流的持久性,Sql Workflow Persistence Service 无法将状态保存在数据库中。

我没有提到的是,我将工作流公开为 WCF 服务,事实证明这对于解决这个问题至关重要。 我向所有试图解决这个缺乏信息的人致歉。

我使用了接收活动,我将其指向 WCF 服务契约方法。 该方法有一个复杂类型的返回值:

[DataContract]
public class ServiceCallInfo
{
    int code;
    [DataMember]
    public int Code
    {
        get { return code; }
        set { code = value; }
    }
    string message;

    [DataMember]
    public string Message
    {
        get { return message; }
        set { message = value; }
    }
}

我将该返回值绑定到工作流的新属性。

public static DependencyProperty ReturnInfoProperty = DependencyProperty.Register("ReturnInfo", typeof(my.mynamespace.ServiceCallInfo), typeof(my.mynamespace.StandardContractingWorkflow));

    [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
    [BrowsableAttribute(true)]
    [CategoryAttribute("Parameters")]
    public my.mynamespace.ServiceCallInfo ReturnInfo
    {
        get
        {
            return ((my.mynamespace.ServiceCallInfo)(base.GetValue(my.mynamespace.ReturnInfoProperty)));
        }
        set
        {
            base.SetValue(my.mynamespace.ReturnInfoProperty, value);
        }
    }

如果我仅在工作流代码中的某个位置实例化此属性,工作流运行时将无法保存状态,如果我不这样做,则状态会正确保存!
我假设,由于某种原因,工作流运行时由于此属性而无法序列化(或使用 Sql 工作流持久性服务保存状态的任何操作)工作流状态。

也许是因为 ServiceCallInfo 类的定义,也许是其他原因......
我希望有更多知识和经验的人能够说出真正的原因是什么......

但是,这个问题已经解决了。

OK, finally, I found out what was the problem.
In the first post I wrote that at first everything worked just as charmed but after some little changes,that should not influence the persisting of the workflow, Sql Workflow Persistence Service was not able to save the state in database.

What I didn't mention the I exposed workflow as a WCF Service, and it turns out that crucial to solve this problem. I apologize to everybody that tried to solve this whit lack of information.

I used the Receive Activity which I pointed to the method WCF Service contract. That method had a return value of complex type:

[DataContract]
public class ServiceCallInfo
{
    int code;
    [DataMember]
    public int Code
    {
        get { return code; }
        set { code = value; }
    }
    string message;

    [DataMember]
    public string Message
    {
        get { return message; }
        set { message = value; }
    }
}

I binded that return value to the new property of the workflow.

public static DependencyProperty ReturnInfoProperty = DependencyProperty.Register("ReturnInfo", typeof(my.mynamespace.ServiceCallInfo), typeof(my.mynamespace.StandardContractingWorkflow));

    [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
    [BrowsableAttribute(true)]
    [CategoryAttribute("Parameters")]
    public my.mynamespace.ServiceCallInfo ReturnInfo
    {
        get
        {
            return ((my.mynamespace.ServiceCallInfo)(base.GetValue(my.mynamespace.ReturnInfoProperty)));
        }
        set
        {
            base.SetValue(my.mynamespace.ReturnInfoProperty, value);
        }
    }

If I only instantiate this property somewhere in the code of the workflow, Workflow Runtime fails to save the state, and if I don't do that state is saved properly!
I assume that, for some reason, Workflow Runtime was not able to serialize (or whatever it does to save the state using Sql Workflow Persistence Service) workflow state because of this property.

Maybe it's because of definition of ServiceCallInfo class, maybe it's something else...
I hope that someone with more knowledge and experience will be able to say what were the real reasons...

However, this problem is solved.

谜兔 2024-07-22 10:41:43

实际上你不需要删除这些变量,你只需要在其上添加 NonSerialized 属性即可

Acctually you don't need to remove those variables, you just need put NonSerialized attribute on its

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文