NServiceBus stores subscriptions in a pub / routine

I want to figure out how to set up a Pub / Sub sample from NServiceBus to work in the event of a publisher failure. When I run samples and accidentally close subscribers, if I restart everything, everything works fine. If, however, I kill the publisher, and the subscriptions continue to work, if I restart the publisher, then he does not seem to know that he has subscribers and does not publish any messages.

I added an entry to the configuration <MsmqSubscriptionStorageConfig Queue = "subscriptions" /> but it does not seem to work ... I'm missing something. I googled about MsmqSubscriptionStorageConfig and DbSubscriptionStorageConfig, but I did not find a solution.

Can someone point me in the right direction?

+4
source share
2 answers

I found that doing this work with a Pub / Sub sample in .Net 4.0 requires a few extra steps using SQLite's subscription storage system.

Combining previous offers with new ones, here are the necessary changes, all of which are related to the MyPublisher project.


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

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

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

     <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 XML fragment to the configuration section of the NServiceBus.Host.exe.config file:

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

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

To debug this path, go to the properties of the publisher project, on the Debug tab, and place NServiceBus.Production in the command line arguments in the Startup Parameters section.

+3
source

Source: https://habr.com/ru/post/1300496/


All Articles