开发者

Unsatisfied dependency expressed through object property

开发者 https://www.devze.com 2023-02-09 21:51 出处:网络
So I am building publisher and following is my config <?xml version=\"1.0\" encoding=\"utf-8\" ?>

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 'NS开发者_如何学PythonerviceBus.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


I just had the same problem, and solved it by calling .CreateBus() at the end of the configuration:

class EndpointConfig : IConfigureThisEndpoint, AsA_Publisher, IWantCustomInitialization
{
    public void Init()
    {
        NServiceBus.Configure.With()
            .Log4Net()
            .DefaultBuilder()
            .XmlSerializer()
            .UnicastBus()
            .ImpersonateSender(false)
            .MsmqTransport()
            .IsTransactional(true)
            .DBSubcriptionStorage()
            .CreateBus();
    }
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消