Dos
Dos

Reputation: 2507

How to set the SQS message class in boto3?

I'm migrating from boto to boto3.

The following snippet sets the message class to my sqs:

conn = boto.sqs.connect_to_region(my_region)
queue = conn.create_queue(queue_name)
queue.set_message_class(boto.sqs.message.RawMessage)

How to do this with boto3?

Upvotes: 0

Views: 1424

Answers (1)

Asdfg
Asdfg

Reputation: 12203

You need to create SQS Client and use it. You don't need to set RawMessage class anymore.

import boto3
client = boto3.client('sqs')
response = client.send_message(
    QueueUrl='string',
    MessageBody='string',
    DelaySeconds=123,
    MessageAttributes={
        'string': {
            'StringValue': 'string',
            'BinaryValue': b'bytes',
            'StringListValues': [
                'string',
            ],
            'BinaryListValues': [
                b'bytes',
            ],
            'DataType': 'string'
        }
    },
    MessageDeduplicationId='string',
    MessageGroupId='string'
)

Source: https://boto3.readthedocs.io/en/latest/reference/services/sqs.html#SQS.Client.send_message

Upvotes: 2

Related Questions