Configuration

Component: Azure Storage Persistence
NuGet Package NServiceBus.Persistence.AzureStorage (1.x)
Target NServiceBus Version: 6.x

In NServiceBus.Persistence.AzureStorage XML-based configuration is no longer available. Configuring the behavior of the persister is done using the code configuration API.

Configuration with Code

For Sagas, Subscriptions and for Timeouts:

var persistence = endpointConfiguration.UsePersistence<AzureStoragePersistence>();
persistence.ConnectionString("connectionString");

For Sagas:

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

// Added in Version 1.4
persistence.AssumeSecondaryIndicesExist();

For Subscriptions:

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

// Added in Version 1.3
persistence.CacheFor(TimeSpan.FromMinutes(1));

For Timeouts:

var persistence = endpointConfiguration.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 connectionstring for the storage account to be used for storing saga information.
  • NServiceBus.Azure defaults to UseDevelopmentStorage=true.
  • NServiceBus.Persistence.AzureStorage Version 1 defaults to null.
  • CreateSchema: Instructs the persister to create the table automatically. Defaults to true.
  • AssumeSecondaryIndicesExist: (Added in Version 1.4) By default every new saga scans for a secondary index. To avoid unnecessary performance tax, this option allows to skip the scans assuming all saga instances are in valid form and have secondary indices.

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 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.

Timeout Configuration

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

  • ConnectionString: Sets the connectionstring for the storage account to be used for storing timeout information.
  • NServiceBus.Azure Versions 6 and below Defaults to UseDevelopmentStorage=true.
  • NServiceBus.Persistence.AzureStorage Version 1 defaults to null.
  • TimeoutManagerDataTableName: Sets the name of the table where the timeout manager stores it's internal state.
  • defaults to TimeoutManagerDataTable.
  • TimeoutDataTableName: Sets the name of the table where the timeouts themselves are stored. Defaults to TimeoutDataTableName.
  • CatchUpInterval: When a node hosting a timeout manager goes down, it needs to catch up with missed timeouts faster than it normally would (1 sec), this value sets the catchup interval in seconds.
  • defaults to 3600, meaning it will process one hour at a time.
  • PartitionKeyScope: The time range used as partition key value for all timeouts. For optimal performance this should be in line with the catchup interval. Data in the table defined by TimeoutDataTableName will need to be migrated when modifying PartitionKeyScope.
  • defaults to yyyMMddHH.
  • TimeoutStateContainerName: Sets the name of the container where the timeout state is stored - Added in NServiceBus.Persistence.AzureStorage Version 1.0.
  • defaults to timeoutstate.

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


Last modified