Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Hybrid Cloud for Developers

You're reading from   Hybrid Cloud for Developers Develop and deploy cost-effective applications on the AWS and OpenStack platforms with ease

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher Packt
ISBN-13 9781788830874
Length 280 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Hirway Hirway
Author Profile Icon Hirway
Hirway
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Title Page
Dedication
Packt Upsell
Contributors
Preface
1. Introducing Hybrid Clouds FREE CHAPTER 2. Exploring AWS Cloud 3. Exploring OpenStack Private Cloud 4. Developing AWS Cloud Applications 5. Developing OpenStack Applications 6. Cloud Migration 7. Hybrid Cloud Best Practices 8. Monitoring and Troubleshooting Hybrid Cloud 9. Hybrid Cloud Security 1. Other Books You May Enjoy Index

Developing Amazon SQS applications – Unix


The boto3 library provides classes for manipulating the SQS queues. We will start by creating the SQS queue using the boto3 library.

Creating an SQS queue

First, create an object of type sqs and then invoke the create_queue() function to create an SQS queue. The response object is a Python dictionary that can then be used to fetch the URL of the queue.

The following Python program creates a queue and fetches the URL of the newly created queue:

import boto3

# Create SQS client
sqs_object = boto3.client('sqs')

response = sqs_object.create_queue(
    QueueName='packtpub_queue',
)

queue_url = response['QueueUrl']


Once the queue is created, let's send a message to it.

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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images