0

从nservicebus版本3升级到版本4,收到如下错误信息

“没有配置消息序列化程序。”

堆栈跟踪:

在 c:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Unicast\UnicastBus.cs:NServiceBus.Unicast.UnicastBus.ValidateConfiguration() 中的 NServiceBus.Unicast.UnicastBus.ValidateConfiguration() 中的第 866 行 NServiceBus.Unicast.UnicastBus.Start(Action startupAction) 在 c :\TeamCity\buildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Unicast\UnicastBus.cs:C:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\NServiceBus 中 NServiceBus.Unicast.UnicastBus.Start() 的第 739 行。 Core\Unicast\UnicastBus.cs: d:\dev\backup\soa_cyclemonkey\Inventory\Inventory.CreateOrder\IT_OPS\CustomInit.cs 中 CycleMonkey.Inventory.CreateOrder.IT_OPS.CustomInit.Init() 的第 718 行:NServiceBus 中的第 20 行.Hosting.Configuration.ConfigManager.ConfigureCustomInitAndStartup() 在 c:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Hosting\Configuration\ConfigurationManager.cs:NServiceBus 的第 43 行。c:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\NServiceBus.Core\Hosting\GenericHost.cs 中的 Hosting.GenericHost.PerformConfiguration():c:\TeamCity\buildAgent 中 NServiceBus.Hosting.GenericHost.Start() 的第 126 行\work\d4de8921a0aabf04\src\NServiceBus.Core\Hosting\GenericHost.cs:C:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\hosting\NServiceBus.Hosting 中 NServiceBus.Hosting.Windows.WindowsHost.Start() 的第 29 行.Windows\WindowsHost.cs:NServiceBus.Hosting.Windows.Program.<>c_ 的第 56 行\TeamCity\buildAgent\work\d4de8921a0aabf04\src\hosting\NServiceBus.Hosting.Windows\WindowsHost.cs:NServiceBus.Hosting.Windows.Program 的第 56 行。<>c_\TeamCity\buildAgent\work\d4de8921a0aabf04\src\hosting\NServiceBus.Hosting.Windows\WindowsHost.cs:NServiceBus.Hosting.Windows.Program 的第 56 行。<>c_DisplayClassd.b _5(WindowsHost 服务)在 c:\TeamCity\buildAgent\work\d4de8921a0aabf04\src\hosting\NServiceBus.Hosting.Windows\Program.cs:Topshelf.Internal.ControllerDelegates 1 的第 76 行1.StartActionObject(Object obj) in c:\Projects\TopShelfForNSB\src\Topshelf\Internal\ControllerDelegates.cs:line 18 at Topshelf.Internal.IsolatedServiceControllerWrapper。<>c_ DisplayClass2.b _1(TService 服务)在 c:\Projects\TopShelfForNSB\src\Topshelf\Internal\IsolatedServiceControllerWrapper.cs:line 65 at Topshelf.Internal.ServiceController 1.<.cctor>b__1(ServiceController1 sc) 在 c:\Projects\TopShelfForNSB\src\Topshelf\Internal\ServiceController。 cs:第 35 行 Magnum.StateMachine.LambdaAction 1.Execute(T instance, Event event, Object parameter) in :line 0 at Magnum.StateMachine.EventActionList1.Execute(T stateMachine, Event event, Object parameter) in :line 0

升级中是否遗漏了什么?正在运行的代码版本 3:

public class EndpointConfig : IConfigureThisEndpoint, AsA_Server
{
}

public class CustomInit : IWantCustomInitialization
    {
                    public void Init()
        {
            Configure.Instance
                     .CastleWindsorBuilder()
                     .DefaultBuilder()
                     .Sagas()
                     .RunTimeoutManagerWithInMemoryPersistence()
                     .ConfigureMongoSagaPersister<CreateOrderSagaData>("mongodb://localhost/create-order");

            Configure.Instance
                     .XmlSerializer()
                     .MsmqSubscriptionStorage()
                     .MsmqTransport()
                     .UnicastBus();

        }
    }

相同代码的第 4 版以及升级所需的建议更改

public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, UsingTransport<Msmq>
{
}

public class CustomInit : IWantCustomInitialization
    {
        public void Init()
        {
            Configure.Features.Enable<Sagas>();
            Configure.Serialization.Xml();

            Configure.Instance
               .CastleWindsorBuilder()
               .UseInMemoryTimeoutPersister()
               .ConfigureMongoSagaPersister<CreateOrderSagaData>("mongodb://localhost/create-order");

            Configure.Instance
                    .MsmqSubscriptionStorage()
                    .UnicastBus()
                    .CreateBus()
                    .Start();
        }

    }
4

1 回答 1

1

When bootstrapping a different container, use the IWantCustomInitialization interface together with the IConfigureThisEndpoint like @JohnSimons mentioned.

Also, when you are implementing the IWantCustomInitialization in the IConfigureThisEndpoint, there is no bus yet, so an instance has not been created at this point, so you'd need to use Configure.With() instead of Configure.Instance.

NOTE: You don't need to specify UsingTransport as Msmq is the default transport. You also don't need to specify Configure.Serialization.Xml() as Xml is the default serializer.

So, if you change your code to something like below, it should work:

public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
    public void Init()
    {
        Configure.Features.Enable<Sagas>();

        Configure.With()
            .CastleWindsorBuilder()
            .UseInMemoryTimeoutPersister()
            .MsmqSubscriptionStorage();

    }
}
于 2013-08-20T08:10:25.193 回答