Sending and receiving messages in Amazon SQS

March 2024 ยท 1 minute read
import boto3 # Create SQS client sqs = boto3.client('sqs') queue_url = 'SQS_QUEUE_URL' # Send message to SQS queue response = sqs.send_message( QueueUrl=queue_url, DelaySeconds=10, MessageAttributes={ 'Title': { 'DataType': 'String', 'StringValue': 'The Whistler' }, 'Author': { 'DataType': 'String', 'StringValue': 'John Grisham' }, 'WeeksOn': { 'DataType': 'Number', 'StringValue': '6' } }, MessageBody=( 'Information about current NY Times fiction bestseller for ' 'week of 12/11/2016.' ) ) print(response['MessageId']) 

ncG1vNJzZmian6m8dHrAppizp56WxLR6wqikaK5hZLGwr9SmnKeskam2sLqOmqeiZ5yWwaa%2F02ierqGUmny0vdJmnLGZnaW5pnnSnqWdoZ6cerOxwp6gr6GenHquv8asZaGsnaE%3D