开发者

NServiceBus persisting subscriptions in Pub/Sub sample

I want to figure out how I to set up the Pub/Sub sample from NServiceBus to work in the case of publisher malfunction. When I start the samples and accidentaly close the Subscribers, if I restart everything works fine. If however I kill the publisher and the subscriptions continue to work, if I restart the publisher, then it doesn't seem to know it has subscribers and doesn't post any messages.

I added the config entry <MsmqSubscriptionStorageConfig Queue="subscriptions"/> but it seems to not functio开发者_Python百科n... I miss something. I googled about MsmqSubscriptionStorageConfig and DbSubscriptionStorageConfig but i didn't find a solution.

Could someone point me in the right direction ?


I found that a couple additional steps are required in order to get this working with the Pub/Sub sample under .Net 4.0, using a SQLite subscription storage system.

Combining the previous suggestions with the new ones, here are the required changes, all of which apply to the MyPublisher project.


  • Add a reference to System.Data.SQLite. Be sure to choose the version that matches your desired architecture (x86/x64). These items can be found in the 'binaries' folder.

  • In the App.config file, add the following as a new configSection element:

    <section name="DBSubscriptionStorageConfig" 
    type="NServiceBus.Config.DBSubscriptionStorageConfig, NServiceBus.Core" />
    
  • In the App.config file add, the following as a new configuration element:

    <DBSubscriptionStorageConfig>
        <NHibernateProperties>
            <add Key="connection.provider" 
                Value="NHibernate.Connection.DriverConnectionProvider"/>
            <add Key="connection.driver_class"
                Value="NHibernate.Driver.SQLite20Driver"/>
            <add Key="connection.connection_string"
                Value="Data Source=.\Subscriptions.sqlite;Version=3;New=True;"/>
            <add Key="dialect"
                Value="NHibernate.Dialect.SQLiteDialect"/>
        </NHibernateProperties>
    </DBSubscriptionStorageConfig>
    
  • Add this chunk of XML to the configuration section of the NServiceBus.Host.exe.config file:

    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>
    </startup>
    


You need to change the profile of the publisher to production. See http://docs.particular.net/nservicebus/hosting/nservicebus-host/profiles

For debugging this way, go to the properties of the publisher project, into the Debug tab, and put in NServiceBus.Production in the Command line arguments of the Start Options section.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜