This sample shows the basic usage of SQS as a transport for NServiceBus. The application sends messages between two endpoints, via the SQS transport, and writes a message to the console when a message is received.
Add the AWS Access Key ID and AWS Secret Access Key to the following environment variables:
- Access Key ID in
- Secret Access Key in
- Default Region in
See also AWS Regions for a list of available regions.
Samples-Sqs-Simple: The main message processing queue.
Samples-Sqs-Simple-Retries: Queue used for delayed retries.
error: Queue used for error handling.
An Amazon S3 bucket is required to leverage the S3 bucket for large messages feature of the SQS transport. Create an S3 bucket and replace the
bucketname in the sample startup with the name of the created bucket.
Configure the endpoints to use the SQS transport.
var endpointConfiguration = new EndpointConfiguration("Samples.Sqs.SimpleSender");
var transport = new SqsTransport
S3 = new S3Settings("bucketname", "my/key/prefix")
var routing = endpointConfiguration.UseTransport(transport);
Start the endpoints. Two console applications will be started, a receiver endpoint can send commands or publish events to the subscriber endpoint. In addition, large message bodies can be sent using S3 as the storage for the message payload.
To view a message in transit, stop the receiver endpoint while sending/publishing further messages from the sender endpoint. The messages will be written to SQS but not dequeued. The message can now be viewed in the SQS management UI.
The large message contents can be viewed in the S3 management UI.