通过对象属性表达的不满足的依赖关系
所以我正在构建发布者,以下是我的配置
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
<section name="DBSubscriptionStorageConfig" type="NServiceBus.Config.DBSubscriptionStorageConfig, NServiceBus.Core" />
</configSections>
<!-- 1. In order to configure remote endpoints use the format: "queue@machine"
2. Input queue must be on the same machine as the process feeding off of it.
3. Error queue can (and often should) be on a different machine.
4. The community edition doesn't support more than one worker thread.
-->
<MsmqTransportConfig
InputQueue="HomeOfficePublisherQueue"
ErrorQueue="error"
NumberOfWorkerThreads="1"
MaxRetries="5"
/>
<DBSubscriptionStorageConfig>
<NHibernateProperties>
<add Key="connection.provider"
Value="NHibernate.Connection.DriverConnectionProvider"/>
<add Key="connection.driver_class"
Value="NHibernate.Driver.SqlClientDriver"/>
<add Key="connection.connection_string"
Value="Server=<dbserver>;initial catalog=NServiceBus;Integrated Security=SSPI"/>
<add Key="dialect"
Value="NHibernate.Dialect.MsSql2005Dialect"/>
</NHibernateProperties>
</DBSubscriptionStorageConfig>
<UnicastBusConfig
DistributorControlAddress=""
DistributorDataAddress=""
ForwardReceivedMessagesTo="">
<MessageEndpointMappings>
</MessageEndpointMappings>
</UnicastBusConfig>
</configuration>
,这是我的端点
class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
public void Init()
{
NServiceBus.Configure.With()
.Log4Net()
.DefaultBuilder()
.XmlSerializer()
.UnicastBus()
.ImpersonateSender(false)
.MsmqTransport()
.IsTransactional(true)
.DBSubcriptionStorage();
}
}
}
启动端点时出现以下异常
异常,已记录错误。原因:创建名为“NServiceBus.Unicast.UnicastBus”的对象时出错:通过对象属性“SubscriptionStorage”表达的依赖关系不满足:有 2 个类型为 [NServiceBus.Unicast.Subscriptions.ISubscriptionStorage] 的对象用于按类型自动装配,而本应有只需 1 即可自动装配对象“NServiceBus.Unicast.UnicastBus”的属性“SubscriptionStorage”。
任何帮助表示赞赏
So I am building publisher and following is my config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
<section name="DBSubscriptionStorageConfig" type="NServiceBus.Config.DBSubscriptionStorageConfig, NServiceBus.Core" />
</configSections>
<!-- 1. In order to configure remote endpoints use the format: "queue@machine"
2. Input queue must be on the same machine as the process feeding off of it.
3. Error queue can (and often should) be on a different machine.
4. The community edition doesn't support more than one worker thread.
-->
<MsmqTransportConfig
InputQueue="HomeOfficePublisherQueue"
ErrorQueue="error"
NumberOfWorkerThreads="1"
MaxRetries="5"
/>
<DBSubscriptionStorageConfig>
<NHibernateProperties>
<add Key="connection.provider"
Value="NHibernate.Connection.DriverConnectionProvider"/>
<add Key="connection.driver_class"
Value="NHibernate.Driver.SqlClientDriver"/>
<add Key="connection.connection_string"
Value="Server=<dbserver>;initial catalog=NServiceBus;Integrated Security=SSPI"/>
<add Key="dialect"
Value="NHibernate.Dialect.MsSql2005Dialect"/>
</NHibernateProperties>
</DBSubscriptionStorageConfig>
<UnicastBusConfig
DistributorControlAddress=""
DistributorDataAddress=""
ForwardReceivedMessagesTo="">
<MessageEndpointMappings>
</MessageEndpointMappings>
</UnicastBusConfig>
</configuration>
and here is my endpoint
class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
public void Init()
{
NServiceBus.Configure.With()
.Log4Net()
.DefaultBuilder()
.XmlSerializer()
.UnicastBus()
.ImpersonateSender(false)
.MsmqTransport()
.IsTransactional(true)
.DBSubcriptionStorage();
}
}
}
I get following exception
Exception when starting endpoint, error has been logged. Reason: Error creating object with name 'NServiceBus.Unicast.UnicastBus' : Unsatisfied dependency expressed through object property 'SubscriptionStorage': There are 2 objects of Type [NServiceBus.Unicast.Subscriptions.ISubscriptionStorage] for autowire by type, when there should have been just 1 to be able to autowire property 'SubscriptionStorage' of object 'NServiceBus.Unicast.UnicastBus'.
Any help is appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚遇到了同样的问题,并通过在配置末尾调用 .CreateBus() 解决了它:
I just had the same problem, and solved it by calling .CreateBus() at the end of the configuration:
仅当角色的设置符合您的要求时才使用这些角色。尝试删除 As_aPublisher 并查看是否适合您。在您的情况下,角色和您自己的代码都会注册一个 sub.storeage,这就是给您带来例外的原因。
Only use the roles if their settings are what you want. Try to remove As_aPublisher and see if that does it for you. In your case both the role and your own code will register a sub.storeage and that is what gives you the exception.