Configuration

Component: Azure Storage Persistence
NuGet Package NServiceBus.Azure (6.x)
Target NServiceBus Version: 5.x
Standard support for version 5.x of NServiceBus has expired. For more information see our Support Policy.

In NServiceBus.Azure the behavior of the AzureStoragePersister can be controlled by working with the appropriate configuration section(s) in the app.config or by using the code via the IProvideConfiguration adapter. Both approaches to configuring the persister can access the same configuration options.

Configuration with Configuration Section

In NServiceBus.Azure configuration can be performed using configuration sections and properties in the app.config file.

<configSections>
  <section name="AzureSubscriptionStorageConfig"
           type="NServiceBus.Config.AzureSubscriptionStorageConfig, NServiceBus.Azure" />
  <section name="AzureSagaPersisterConfig"
           type="NServiceBus.Config.AzureSagaPersisterConfig, NServiceBus.Azure" />
  <section name="AzureTimeoutPersisterConfig"
           type="NServiceBus.Config.AzureTimeoutPersisterConfig, NServiceBus.Azure" />
</configSections>
<AzureSagaPersisterConfig ConnectionString="UseDevelopmentStorage=true" />
<AzureTimeoutPersisterConfig ConnectionString="UseDevelopmentStorage=true" />
<AzureSubscriptionStorageConfig ConnectionString="UseDevelopmentStorage=true" />

Configuration with code

For sagas:

var persistence = busConfiguration.UsePersistence<AzureStoragePersistence, StorageType.Sagas>();
persistence.ConnectionString("connectionString");
persistence.CreateSchema(true);

For subscriptions:

var persistence = busConfiguration.UsePersistence<AzureStoragePersistence, StorageType.Subscriptions>();
persistence.ConnectionString("connectionString");
persistence.TableName("tableName");
persistence.CreateSchema(true);

For timeouts:

var persistence = busConfiguration.UsePersistence<AzureStoragePersistence, StorageType.Timeouts>();
persistence.ConnectionString("connectionString");
persistence.CreateSchema(true);
persistence.TimeoutManagerDataTableName("TimeoutManager");
persistence.TimeoutDataTableName("TimeoutData");
persistence.CatchUpInterval(3600);
persistence.PartitionKeyScope("yyyy-MM-dd-HH");

Configuration properties

Each area of the persister (sagas, subscriptions and timeouts) have values that can be set or changed.

Saga configuration

The following settings are available for changing the behavior of saga persistence section:

  • ConnectionString: Sets the connection string for the storage account to be used for storing saga information.
  • NServiceBus.Azure defaults to UseDevelopmentStorage=true.
  • NServiceBus.Persistence.AzureStorage version 1 and above defaults to null.
  • CreateSchema: Instructs the persister to create the table automatically. Defaults to true.
  • AssumeSecondaryIndicesExist (Added in version 1.4): Disables scanning for secondary index records when checking if a new saga should be created. A secondary index record was not created by the persister contained in the NServiceBus.Azure package. To provide backward compatibilty, the NServiceBus.Persistence.AzureStorage package performs a full table scan, across all partitions, for secondary index records before creating a new saga. For systems that have only used the NServiceBus.Persistence.AzureStorage library, or have verified that all saga instances have a secondary index record, full table scans can be safely disabled by using this configuration setting.

Subscription configuration

The following settings are available for changing the behavior of subscription persistence:

  • ConnectionString: Sets the connection string for the storage account to be used for storing subscription information.
  • NServiceBus.Azure defaults to UseDevelopmentStorage=true.
  • NServiceBus.Persistence.AzureStorage version 1 and above defaults to null.
  • CreateSchema: Instructs the persister to create the table automatically. Defaults to true.
  • TableName: Specifies the name of the table for storing subscriptions. Defaults to Subscription.
  • CacheFor (Added in Version 1.3): By default every time a message is published the subscription storage is queried. In scenarios where the list of subscribers rarely changes, this query is often redundant and can slow down message processing. CacheFor allows subscriptions to be cached for a given period of time, hence helping reduce the impact of redundant queries to the subscription store.

For more information on connection string configuration see Configuring Azure Connection Strings.


Last modified