Send a message to a queue

    0

    1

    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'])
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.