NServiceBus从v3升级到v4:未调用OracleMessageModule.Begin()

时间:2014-05-19 13:00:07

标签: upgrade nservicebus

升级前的工作代码。 HandleBeginMessage()会自动调用:

public class OracleMessageModule : IMessageModule
{
    public OracleMessageModule()
    {
        Factory = new OracleSagaSessionFactory();
    }

    public OracleSagaSessionFactory Factory { get; set; }

    public void HandleBeginMessage()
    {
        Factory.Begin();
    }

    public void HandleEndMessage()
    {
        Factory.Complete();
    }

    public void HandleError()
    {
        Factory.Complete();
    }
}

升级到v4后代码不再工作。 Begin()不会自动调用:

public class OracleMessageModule : UnitOfWork.IManageUnitsOfWork
{
    public OracleMessageModule()
    {
        Factory = new OracleSagaSessionFactory();
    }

    public OracleSagaSessionFactory Factory { get; set; }

    public void Begin()
    {
        Factory.Begin();
    }

    public void End(System.Exception ex = null)
    {
        Factory.Complete();
    }
}

1 个答案:

答案 0 :(得分:3)

IManageUnitsOfWork未自动注册。您需要明确注册您的工作单元。

有关如何操作的详细信息,请参阅此处:

http://docs.particular.net/nservicebus/unit-of-work-in-nservicebus#registering-your-unit-of-work