AWS and boto3 recipes for Python
The following code creates and sends a message to the SQS queue.
The QueueUrl parameter sets the URL to the queue where the message will be sent. The DelaySeconds parameter sets the delay, in seconds, for the message to be sent. The MessageAttributes parameter specifies the message attributes, such as the queue name and the message body. The MessageBody parameter specifies the message body.
import boto3
# Create SQS client
sqs = boto3.client('sqs')
# Send message to SQS queue
response = sqs.send_message(
QueueUrl=queueurl,
DelaySeconds=10,
MessageAttributes=messageattr,
MessageBody=(messagebody)
)
print(response['MessageId'])