Azure Service Bus Transport Upgrade Version 7 to 8

Forwarding topology number of entities in bundle removed

In Versions 8 and above the API to configure bundle prefix and number of entities in a bundle has been removed:

7.x - 7.2.3 NServiceBus.Azure.Transports.WindowsAzureServiceBus
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
var forwardingTopology = transport.UseForwardingTopology();

forwardingTopology.BundlePrefix("my-prefix");
forwardingTopology.NumberOfEntitiesInBundle(3);

The bundle is set to one entity. For existing endpoints running with multiple entities in a bundle, the transport automatically picks up previously configured entities. The default topic name for bundle is set to bundle-1.

See also Azure Service Bus Transport Topologies.

Controlling entity creation

Controlling entity creation has been simplified. Instead of having to provide a full implementation of DescriptionFactory where all settings on the description object had to be provided, a customizer (DescriptionCustomizer) has been introduced where only the customized properties can be changed. DescriptionCustomizer can be found on the Queues, Topics and Subscriptions API extension points.

Queue and Subscription MaxDeliveryCount

In version 7 the transport sets MaxDeliveryCount to match immediate retries specified by each endpoint to ensure messages are not dead-lettered accidentally.

In version 8 and above, MaxDeliveryCount is set to int.MaxValue to ensure messages are not dead-lettered accidentally and to remove the dependency on the endpoints' immediate retries configuration.

Customization of MaxDeliveryCount is strongly discouraged, yet can be performed using DescriptionCustomizer API for queues and topics.

BrokeredMessage conventions

Due to complexity, and resultant risk, of implementation, the API to specify how the BrokeredMessage body is stored and retrieved by overriding the default conventions is obsoleted and the following methods were deprecated:

7.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
transport.UseBrokeredMessageToIncomingMessageConverter<CustomIncomingMessageConversion>();
7.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
transport.UseOutgoingMessageToBrokeredMessageConverter<CustomOutgoingMessageConversion>();

Serialization is mandatory

In Versions 7 and below, the transport was setting the default serialization. In Versions 8 and above, the transport is no longer sets the default serialization. Instead, it should be configured.

For backwards compatibility, NServiceBus.Newtonsoft.Json serializer should be used.

9.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
endpointConfiguration.UseSerialization<NewtonsoftSerializer>();
8.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
endpointConfiguration.UseSerialization<NewtonsoftSerializer>();

Send/publish namespaces caching

In Version 7 to control sending/publishing namespaces caching, the transport must provide an implementation of two contracts.

9.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
public class CustomNamespacePartitioningStrategy :
    INamespacePartitioningStrategy
{
    ReadOnlySettings settings;

    public CustomNamespacePartitioningStrategy(ReadOnlySettings settings)
    {
        this.settings = settings;
    }

    public IEnumerable<RuntimeNamespaceInfo> GetNamespaces(PartitioningIntent partitioningIntent)
    {
        throw new NotImplementedException();
    }

    public bool SendingNamespacesCanBeCached { get; }
}
8.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
public class CustomNamespacePartitioningStrategy :
    INamespacePartitioningStrategy
{
    ReadOnlySettings settings;

    public CustomNamespacePartitioningStrategy(ReadOnlySettings settings)
    {
        this.settings = settings;
    }

    public IEnumerable<RuntimeNamespaceInfo> GetNamespaces(PartitioningIntent partitioningIntent)
    {
        throw new NotImplementedException();
    }

    public bool SendingNamespacesCanBeCached { get; }
}
7.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
public class MyNamespacePartitioningStrategyWithControlledCaching :
    INamespacePartitioningStrategy, ICacheSendingNamespaces
{
    ReadOnlySettings settings;

    public MyNamespacePartitioningStrategyWithControlledCaching(ReadOnlySettings settings)
    {
        this.settings = settings;
    }

    public IEnumerable<RuntimeNamespaceInfo> GetNamespaces(PartitioningIntent partitioningIntent)
    {
        throw new NotImplementedException();
    }

    public bool SendingNamespacesCanBeCached { get; } = false;
}

From Versions 8 and above, only a single contract is required.

9.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
public class MyNamespacePartitioningStrategy :
    INamespacePartitioningStrategy
{
    public IEnumerable<RuntimeNamespaceInfo> GetNamespaces(PartitioningIntent partitioningIntent)
    {
        throw new System.NotImplementedException();
    }

    public bool SendingNamespacesCanBeCached { get; }
}
8.x NServiceBus.Azure.Transports.WindowsAzureServiceBus
public class MyNamespacePartitioningStrategy :
    INamespacePartitioningStrategy
{
    public IEnumerable<RuntimeNamespaceInfo> GetNamespaces(PartitioningIntent partitioningIntent)
    {
        throw new System.NotImplementedException();
    }

    public bool SendingNamespacesCanBeCached { get; }
}

Related Articles


Last modified