New Configuration API
In versions 6 and below, the Azure Storage Queues transport was configured using an XML configuration section called AzureStorageQueueTransportConfiguration
. This section has been removed in favor of a more granular, code-based configuration API.
The new configuration API is accessible through extension methods on the UseTransport
extension point in the endpoint configuration. See also: Azure Storage Queues Configuration.
var transport = endpointConfiguration.UseTransport<AzureStorageQueueTransport>();
// Configure the transport
transport.ConnectionString("The Connection String");
To continue reading from app.config
Add the following to the project's app.config:
<configuration>
<appSettings>
<add key="AzureStorageQueueConnection"
value="The Connection String" />
</appSettings>
</configuration>
Then read from app.config and pass the value to the transport configuration:
var transport = endpointConfiguration.UseTransport<AzureStorageQueueTransport>();
var connection = ConfigurationManager.AppSettings["AzureStorageQueueConnection"];
transport.ConnectionString(connection);
Setting the configuration values via API
Setting the configuration values can now be done through the API as follows:
- ConnectionString
- BatchSize
- MaximumWaitTimeWhenIdle
- DegreeOfReceiveParallelism
- PeekInterval
- MessageInvisibleTime
These values can be set using corresponding extension methods:
// For Azure Storage Queues Transport version 11.x
var transport = new AzureStorageQueueTransport(queueServiceClient, blobServiceClient, cloudTableClient)
{
ReceiverBatchSize = 20,
MaximumWaitTimeWhenIdle = TimeSpan.FromSeconds(1),
DegreeOfReceiveParallelism = 16,
PeekInterval = TimeSpan.FromMilliseconds(100),
MessageInvisibleTime = TimeSpan.FromSeconds(30)
};
endpointConfiguration.UseTransport(transport);
// For Azure Storage Queues Transport version 10.x
var transport = endpointConfiguration.UseTransport<AzureStorageQueueTransport>();
transport.ConnectionString("DefaultEndpointsProtocol=https;AccountName=[ACCOUNT];AccountKey=[KEY];");
transport.BatchSize(20);
transport.MaximumWaitTimeWhenIdle(TimeSpan.FromSeconds(1));
transport.DegreeOfReceiveParallelism(16);
transport.PeekInterval(TimeSpan.FromMilliseconds(100));
transport.MessageInvisibleTime(TimeSpan.FromSeconds(30));
transport.UseQueueServiceClient(queueServiceClient);
transport.UseBlobServiceClient(blobServiceClient);
transport.UseCloudTableClient(cloudTableClient);
// For Azure Storage Queues Transport version 9.x
var transport = endpointConfiguration.UseTransport<AzureStorageQueueTransport>();
transport.ConnectionString("DefaultEndpointsProtocol=https;AccountName=[ACCOUNT];AccountKey=[KEY];");
transport.BatchSize(20);
transport.MaximumWaitTimeWhenIdle(TimeSpan.FromSeconds(1));
transport.DegreeOfReceiveParallelism(16);
transport.PeekInterval(TimeSpan.FromMilliseconds(100));
transport.MessageInvisibleTime(TimeSpan.FromSeconds(30));
transport.UseQueueServiceClient(queueServiceClient);
transport.UseBlobServiceClient(blobServiceClient);
transport.UseCloudTableClient(cloudTableClient);
// For Azure Storage Queues Transport version 8.x
var transport = endpointConfiguration.UseTransport<AzureStorageQueueTransport>();
transport.ConnectionString("DefaultEndpointsProtocol=https;AccountName=[ACCOUNT];AccountKey=[KEY];");
transport.BatchSize(20);
transport.MaximumWaitTimeWhenIdle(TimeSpan.FromSeconds(1));
transport.DegreeOfReceiveParallelism(16);
transport.PeekInterval(TimeSpan.FromMilliseconds(100));
transport.MessageInvisibleTime(TimeSpan.FromSeconds(30));
// For Azure Storage Queues Transport version 7.x
var transport = endpointConfiguration.UseTransport<AzureStorageQueueTransport>();
transport.ConnectionString("DefaultEndpointsProtocol=https;AccountName=[ACCOUNT];AccountKey=[KEY];");
transport.BatchSize(20);
transport.MaximumWaitTimeWhenIdle(TimeSpan.FromSeconds(1));
transport.DegreeOfReceiveParallelism(16);
transport.PeekInterval(TimeSpan.FromMilliseconds(100));
transport.MessageInvisibleTime(TimeSpan.FromSeconds(30));
PurgeOnStartup
The PurgeOnStartup
setting now can be set on EndpointConfiguration
using an extension method.
endpointConfiguration.PurgeOnStartup(true);
DefaultQueuePerInstance
The DefaultQueuePerInstance
setting is deprecated.
Default value changes
The default values of the following settings have been changed:
- ConnectionString, which had a default value of
UseDevelopmentStorage=true
, was removed and became mandatory. - BatchSize changed from 10 to 32.
Serialization
In previous versions of the Azure Storage Queues transport, change the default SerializationDefinition
to JsonSerializer
.
In version 6 of NServiceBus, transports don't have the ability to manipulate serialization. To preserve backward compatibility and ensure that message payloads are small, setting JSON serialization should now be done on the endpoint configuration level.
endpointConfiguration.UseSerialization<JsonSerializer>();
endpointConfiguration.UseTransport<AzureStorageQueueTransport>();
API Changes
In version 7 of the Azure Storage Queues transport, the public API has been reduced. As a result, multiple classes that used to be public in version 6 and below were marked as obsolete with a comment:
This class served only internal purposes without providing any extensibility point and as such was removed from the public API. For more information, refer to the documentation.
If code exists that depends on classes that were deprecated with the above message, and it is not clear how to update it, contact Particular support to get help in resolving the issue.