Upgrade AmazonSQS Transport Version 3 to 4

MaxTTLDays renamed MaxTimeToLive

The MaxTTLDays method has been renamed to MaxTimeToLive and now takes a TimeSpan

4.x NServiceBus.AmazonSQS
var transport = endpointConfiguration.UseTransport<SqsTransport>();
transport.MaxTimeToLive(TimeSpan.FromDays(10));
3.x NServiceBus.AmazonSQS
var transport = endpointConfiguration.UseTransport<SqsTransport>();
transport.MaxTTLDays(10);

Region

To specify a region set the AWS_REGION environment variable or overload the client factory.

4.x NServiceBus.AmazonSQS
var transport = endpointConfiguration.UseTransport<SqsTransport>();
transport.ClientFactory(() => new AmazonSQSClient(
    new AmazonSQSConfig {
        RegionEndpoint = RegionEndpoint.APSoutheast2
    }));

Credential source

The SDK credential source is picked up automatically.

4.x NServiceBus.AmazonSQS
// picks up credentials as specified by the Amazon SDK
var transport = endpointConfiguration.UseTransport<SqsTransport>();

If desired the credential source can be configured manually by overloading the client factory.

4.x NServiceBus.AmazonSQS
var transport = endpointConfiguration.UseTransport<SqsTransport>();
// SqsCredentialSource.InstanceProfile
transport.ClientFactory(() => new AmazonSQSClient(new InstanceProfileAWSCredentials()));
// SqsCredentialSource.EnvironmentVariables
transport.ClientFactory(() => new AmazonSQSClient(new EnvironmentVariablesAWSCredentials()));

Proxy

Previous versions automatically read the proxy username and password from NSERVICEBUS_AMAZONSQS_PROXY_AUTHENTICATION_USERNAME and NSERVICEBUS_AMAZONSQS_PROXY_AUTHENTICATION_PASSWORD respectively. To achieve the same behavior the client factory has to be overridden:

4.x NServiceBus.AmazonSQS
var userName = Environment.GetEnvironmentVariable("NSERVICEBUS_AMAZONSQS_PROXY_AUTHENTICATION_USERNAME");		
var password = Environment.GetEnvironmentVariable("NSERVICEBUS_AMAZONSQS_PROXY_AUTHENTICATION_PASSWORD");

var transport = endpointConfiguration.UseTransport<SqsTransport>();
transport.ClientFactory(() => new AmazonSQSClient(
    new AmazonSQSConfig { 
        ProxyCredentials = new NetworkCredential(userName, password),
        ProxyHost = "127.0.0.1", 
        ProxyPort = 8888 
    }));

S3 configuration

The possibility to configure the S3 bucket and the key prefix has been moved to a dedicated configuration API for S3 related settings.

4.x NServiceBus.AmazonSQS
var transport = endpointConfiguration.UseTransport<SqsTransport>();
var s3Configuration = transport.S3("bucketname", "keyprefix");

Region

To specify a region set the AWS_REGION environment variable or overload the client factory.

4.x NServiceBus.AmazonSQS
var transport = endpointConfiguration.UseTransport<SqsTransport>();
var s3Configuration = transport.S3(bucketName, keyPrefix);
s3Configuration.ClientFactory(() => new AmazonS3Client(
    new AmazonS3Config { 
        RegionEndpoint = RegionEndpoint.APSoutheast2
    }));

Credential source

The SDK credential source is picked up automatically.

4.x NServiceBus.AmazonSQS
var transport = endpointConfiguration.UseTransport<SqsTransport>();

// picks up credentials as specified by the Amazon SDK
var s3Configuration = transport.S3(bucketName, keyPrefix);

If desired the credential source can be configured manually by overloading the client factory.

4.x NServiceBus.AmazonSQS
var transport = endpointConfiguration.UseTransport<SqsTransport>();
var s3Configuration = transport.S3(bucketName, keyPrefix);
// SqsCredentialSource.InstanceProfile
s3Configuration.ClientFactory(() => new AmazonS3Client(new InstanceProfileAWSCredentials()));
// or SqsCredentialSource.EnvironmentVariables
s3Configuration.ClientFactory(() => new AmazonS3Client(new EnvironmentVariablesAWSCredentials()));

Proxy

Previous versions automatically read the proxy username and password from NSERVICEBUS_AMAZONSQS_PROXY_AUTHENTICATION_USERNAME and NSERVICEBUS_AMAZONSQS_PROXY_AUTHENTICATION_PASSWORD respectively. To achieve the same behavior the client factory has to be overridden:

4.x NServiceBus.AmazonSQS
var userName = Environment.GetEnvironmentVariable("NSERVICEBUS_AMAZONSQS_PROXY_AUTHENTICATION_USERNAME");
var password = Environment.GetEnvironmentVariable("NSERVICEBUS_AMAZONSQS_PROXY_AUTHENTICATION_PASSWORD");

var transport = endpointConfiguration.UseTransport<SqsTransport>();
var s3Configuration = transport.S3(bucketName, keyPrefix);
s3Configuration.ClientFactory(() => new AmazonS3Client(
    new AmazonS3Config { 
        ProxyCredentials = new NetworkCredential(userName, password),
        ProxyHost = "127.0.0.1", 
        ProxyPort = 8888 
    }));

Native deferral

The native deferral API has been deprecated because the transport does not use the timeout manager, so native deferral cannot be disabled.

Unrestricted delayed delivery

By default, it is possible to send delays natively up to 15 min (900 seconds). A new unrestricted delayed delivery mechanism has been added to remove this restriction:

4.x NServiceBus.AmazonSQS
var transport = endpointConfiguration.UseTransport<SqsTransport>();
transport.UnrestrictedDurationDelayedDelivery();

Consult the delayed delivery documentation for more information.

Permissions

In addition to the previous permissions, the GetQueueAttributes permission is required to run SQS transport. The following permissions must be granted to run SQS transport.

SQS permissions

  • CreateQueue
  • DeleteMessage
  • DeleteMessageBatch
  • GetQueueUrl
  • ReceiveMessage
  • SendMessage
  • SendMessageBatch
  • SetQueueAttributes
  • GetQueueAttributes
  • ChangeMessageVisibility
  • ChangeMessageVisibilityBatch
  • PurgeQueue

Last modified