如何解决与NHibernateSagaPersister的自动布线冲突? [英] How do I resolve an autowire conflict with NHibernateSagaPersister?
问题描述
我正在尝试连接我的第一个Saga,并且无法让接收端点正确处理启动消息。我得到以下异常:
I'm trying to wire up my first Saga, and have been unable to get the receiving endpoint to handle start message properly. I get the following exception:
SagaMessageHandler处理
消息失败。
Spring.Objects.Factory.UnsatisfiedDependencyException:
创建名为$ b的对象时出错$ b'NServiceBus.Sagas.Impl.SagaMessageHandler'
:不满意的依赖表达式
通过对象属性' Persister':
有两个对象类型
[NServiceBus.Saga.ISagaPersister]为
autowire按类型,当应该
只有1能够到
autowire属性
对象的Persister
'NServiceBus.Sagas.Impl.SagaMessageHandler'。
SagaMessageHandler Failed handling message. Spring.Objects.Factory.UnsatisfiedDependencyException: Error creating object with name 'NServiceBus.Sagas.Impl.SagaMessageHandler' : Unsatisfied dependency expressed through object property 'Persister': There are 2 objects of Type [NServiceBus.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'.
我猜,内存持久性和NHibernateSagaPersister是冲突,但我不知道如何解决这个问题。我的配置是:
I'm guessing that both the in-memory persister and NHibernateSagaPersister are conflicting, but I can't figure out how to resolve this. My configuration is this:
public class SubscriberEndpointConfig : IWantCustomInitialization, IConfigureThisEndpoint
{
public void Init()
{
_logger.Info("Subscriber is initializing..");
Configure.With()
.DefaultBuilder()
.XmlSerializer()
.MsmqTransport().IsTransactional(true).IsolationLevel(IsolationLevel.ReadCommitted).PurgeOnStartup(false)
.UnicastBus().LoadMessageHandlers(First<GridInterceptingMessageHandler>.Then<SagaMessageHandler>())
.Sagas()
.NHibernateSagaPersister()
.Log4Net();
}
}
如果我删除LoadMessageHandlers ,错误消失,但当然我的处理程序从未调用。任何想法在这里错了什么?当我在生产配置文件中使用AsA_Server时,saga工作正常,没有自定义初始化,但是我需要使用它为其他原因。
If I remove the LoadMessageHandlers(), the error disappears but of course my handler is never invoked. Any ideas what's wrong here? The saga works properly when I am using AsA_Server in the production profile, without the custom initialization, but I need to use that for other reasons.
推荐答案
nservicebus配置文件正在为您配置持久性配置(http://www.nservicebus.com/Profiles.aspx)
The nservicebus profiles are configuring the persister for you(http://www.nservicebus.com/Profiles.aspx)
NServiceBus.Lite(默认)= InMemory
NServiceBus.Lite (default) = InMemory
NServiceBus.Integration = NHibernate + Sqlite
NServiceBus.Integration = NHibernate + Sqlite
NServiceBus.Production = NHibernate
NServiceBus.Production = NHibernate
所以在你的情况下,你可以删除对NHibernateSagaPersister()的调用,让配置文件工作。
So in your case you can remove the call to NHibernateSagaPersister() and let the profiles do it's work.
这篇关于如何解决与NHibernateSagaPersister的自动布线冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!