所以我正在构建发布者,以下是我的配置
<?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'表示的不满意依赖关系:类型为[NServiceBus.Unicast.Subscriptions.ISubscriptionStorage]的2个对象按类型自动装配,应该有只需1即可自动装配对象'NServiceBus.Unicast.UnicastBus'的属性'SubscriptionStorage'。
感谢任何帮助
答案 0 :(得分:1)
我遇到了同样的问题,并通过在配置结束时调用.CreateBus()解决了这个问题:
class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
public void Init()
{
NServiceBus.Configure.With()
.Log4Net()
.DefaultBuilder()
.XmlSerializer()
.UnicastBus()
.ImpersonateSender(false)
.MsmqTransport()
.IsTransactional(true)
.DBSubcriptionStorage()
.CreateBus();
}
}
答案 1 :(得分:0)
如果他们的设置符合您的要求,则仅使用角色。尝试删除As_aPublisher,看看是否适合你。在您的情况下,角色和您自己的代码都将注册一个sub.storeage,这就是为您提供异常。