如何解决与 NHibernateSagaPersister 的自动装配冲突?
我正在尝试连接我的第一个 Saga,但无法让接收端点正确处理启动消息。我得到以下异常:
SagaMessageHandler 处理失败 信息。 Spring.Objects.Factory.UnsatisfiedDependencyException: 使用名称创建对象时出错 'NServiceBus.Sagas.Impl.SagaMessageHandler' :表达出未满足的依赖性 通过对象属性“Persister”: 有 2 个 Type 对象 [NServiceBus.Saga.ISagaPersister] 为 按类型自动装配,当需要时 已经只有 1 能够 autowire 属性 'Persister' of 目的 'NServiceBus.Sagas.Impl.SagaMessageHandler'。
我猜测内存持久程序和 NHibernateSagaPersister 都存在冲突,但我不知道如何解决这个问题。我的配置是这样的:
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 时,传奇可以正常工作,无需自定义初始化,但由于其他原因我需要使用它。
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 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'.
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();
}
}
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
nservicebus 配置文件正在为您配置持久化器(http://www.nservicebus.com/Profiles.aspx)
NServiceBus.Lite (默认)= InMemory
NServiceBus.Integration = NHibernate + Sqlite
NServiceBus.Production = NHibernate
因此,在您的情况下,您可以删除对 NHibernateSagaPersister() 的调用并让配置文件完成它的工作。
The nservicebus profiles are configuring the persister for you(http://www.nservicebus.com/Profiles.aspx)
NServiceBus.Lite (default) = InMemory
NServiceBus.Integration = NHibernate + Sqlite
NServiceBus.Production = NHibernate
So in your case you can remove the call to NHibernateSagaPersister() and let the profiles do it's work.