This example shows you how to:
- Change visibility timeout with queues
You can download complete versions of these example files from the aws-doc-sdk-examples <sqs>
repository on GitHub.
This example manages visibility timeout with queues. It uses these methods of the client class:
CreateQueue <service/sqs/#SQS.CreateQueue>
ListQueues <service/sqs/#SQS.ListQueues>
GetQueueUrl <service/sqs/#SQS.GetQueueUrl>
DeleteQueue <service/sqs/#SQS.DeleteQueue>
- You have
set up <setting-up>
andconfigured <configuring-sdk>
the . - You are familiar with using visibility timeout. To learn more, see
Visibility Timeout <sqs-visibility-timeout>
in the .
Create a new Go file named sqs_changingvisibility.go
.
You must import the relevant Go and packages by adding the following lines.
example_code/sqs/sqs_changingvisibility.go
Initialize a session that the SDK will use to load credentials from the shared credentials file, ~/.aws/credentials.
example_code/sqs/sqs_changingvisibility.go
Get a message from the queue. Call ReceiveMessage
. Pass in the URL of the queue to return details of the next message in the queue. Print any errors, or a message if no message was received.
example_code/sqs/sqs_changingvisibility.go
If a message was returned, use its receipt handle to set the timeout to 30 seconds.
example_code/sqs/sqs_changingvisibility.go