2012-07-29 84 views
0

我是nServiceBus的新手。nServiceBus传奇nHibernate

nServiceBus版本:2.6.0.1505

我想在数据库中坚持传奇。 为什么这不起作用:

public class MessageEndpoint : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization 
{ 
    public void Init() 
    { 
     Configure.With().DefaultBuilder().Sagas().NHibernateSagaPersister(); 
    } 
} 

它抛出一个错误:

Exception occurred in Topshelf.Internal.ServiceController`1[[NServiceBus.Host.Internal.GenericHost, NServiceBus.Host, Version=2.6.0.1505, Culture=neutral, PublicKeyToken=9fc386479f8a226c]] during state Initial while handling OnStart

是否有可能以该方法配置端点在这个版本nServiceBus的?

编辑:

端点配置更改为:

public class MessageEndpoint : IConfigureThisEndpoint, 
    AsA_Server, 
    IWantCustomInitialization 
{ 
    public void Init() 
    { 
     Configure.With() 
      .DefaultBuilder() 
      .XmlSerializer() 
      .Sagas() 
      .NHibernateSagaPersister(); 
    } 
} 

佐贺执行,但会抛出异常:

2012-07-30 16:36:12,229 [Worker.5] INFO NServiceBus.Unicast.UnicastBus [(null)] <(null)> - Received message Messages.StartCmd, Messages, Version=1.0.0.0, Cultu re=neutral, PublicKeyToken=null with ID 0adbb2fd-4a7d-4fa2-ae09-70bbcbbc8241\206 9 from sender [email protected] 2012-07-30 16:36:12,232 [Worker.5] INFO NServiceBus.Unicast.UnicastBus [(null)] <(null)> - Can't impersonate because no windows identity specified in incoming message. This is common in interop scenarios.

2012-07-30 16:36:12,294 [Worker.5] WARN NServiceBus.Unicast.Transport.Msmq.Msmq Transport [(null)] <(null)> - Failed raising 'transport message received' event for message with ID=0adbb2fd-4a7d-4fa2-ae09-70bbcbbc8241\2069 Spring.Objects.Factory.UnsatisfiedDependencyException: Error creating object wit h name 'NServiceBus.Sagas.Impl.SagaMessageHandler' : Unsatisfied dependency expr essed through object property 'Persister': There are 2 objects of Type [NService Bus.Saga.ISagaPersister] for autowire by type, when there should have been just 1 to be able to autowire property 'Persister' of object 'NServiceBus.Sagas.Impl. SagaMessageHandler'. at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.Autowi reByType(String name, RootObjectDefinition definition, IObjectWrapper wrapper, M utablePropertyValues properties) at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.Popula teObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper) at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.Config ureObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper) at Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.Instan tiateObject(String name, RootObjectDefinition definition, Object[] arguments, Bo olean allowEagerCaching, Boolean suppressConfigure)
at Spring.Objects.Factory.Support.AbstractObjectFactory.GetObjectInternal(Str ing name, Type requiredType, Object[] arguments, Boolean suppressConfigure) at Spring.Objects.Factory.Support.AbstractObjectFactory.GetObject(String name) at Spring.Objects.Factory.Support.DefaultListableObjectFactory.GetObjectsOfTy pe(Type type, Boolean includePrototypes, Boolean includeFactoryObjects) at Spring.Context.Support.AbstractApplicationContext.GetObjectsOfType(Type ty pe, Boolean includePrototypes, Boolean includeFactoryObjects) at NServiceBus.ObjectBuilder.Spring.SpringObjectBuilder.NServiceBus.ObjectBui lder.Common.IContainer.Build(Type typeToBuild) at NServiceBus.ObjectBuilder.Common.CommonObjectBuilder.NServiceBus.ObjectBui lder.IBuilder.BuildAndDispatch(Type typeToBuild, Action`1 action)
at NServiceBus.Unicast.UnicastBus.DispatchMessageToHandlersBasedOnType(IMessa ge toHandle, Type messageType) at NServiceBus.Unicast.UnicastBus.HandleMessage(TransportMessage m) at NServiceBus.Unicast.UnicastBus.TransportMessageReceived(Object sender, Tra nsportMessageReceivedEventArgs e) at NServiceBus.Unicast.Transport.Msmq.MsmqTransport.OnTransportMessageReceive d(TransportMessage msg)

看起来这就是为什么它失败的原因:

There are 2 objects of Type [NService Bus.Saga.ISagaPersister] for autowire by type, when there should have been just 1 to be able to autowire property 'Persister' of object 'NServiceBus.Sagas.Impl. SagaMessageHandler'

+0

你检查出的英雄传奇的例子,装NSB?你有佐贺配置集? – 2012-07-29 21:29:47

+0

我在配置文件中有NHibernateSagaPersisterConfig部分。 – 2012-07-29 22:49:51

回答

0

在.DefaultBuilder之后,您很可能会缺少.XmlSerializer(或者如果需要的话,可以是二进制文件),但只是为了确保 - 请包含完整的堆栈跟踪。

+0

我更新了问题,之后我发现了一个解决方案 - http://stackoverflow.com/questions/6629726/how-do-i-resolve-an-autowire-conflict-with-nhibernatesagapersister – 2012-07-30 14:27:00