Sending a message to the queue

Using the SQS object, invoke the send_message() function and pass the queue URL, delay time, message, and the message attributes to it. The message attributes hold the metadata related to the actual message.

The following code snippet sends a message to the queue:

# Send message to SQS queue
response = sqs_object.send_message(
QueueUrl=queue_url,
DelaySeconds=10,
MessageAttributes={
'Title': {
'DataType': 'String',
'StringValue': 'Hybrid Cloud for Developers'
},
'Author': {
'DataType': 'String',
'StringValue': 'Manoj Hirway'
},
'Publisher': {
'DataType': 'String',
'StringValue': 'packt publication'
}
},
MessageBody=(
'Welcome, hybrid cloud developers '
)
)

When a message is successfully sent to the queue, the other side of the application should be able to receive it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.75.133