Upgrade AmazonSQS Transport Version 3 to 4

Component: Amazon SQS Transport
This page targets a pre-release version and is subject to change prior to the final release.

MaxTTLDays renamed MaxTimeToLive

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

4-pre 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-pre 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-pre 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-pre 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 overriden like shown below.

4-pre 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-pre 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-pre 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-pre 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-pre 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 overriden like shown below.

4-pre 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 
    }));

Last modified