0% found this document useful (0 votes)
87 views

Difference Between SQS Visibility Timeout and Delay Queue

Uploaded by

New DSP
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
87 views

Difference Between SQS Visibility Timeout and Delay Queue

Uploaded by

New DSP
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

6/11/22, 1:49 PM Difference between SQS Visibility Timeout and Delay Queue

Flat 25% off on GCP courses | Full Training Package | Use Coupon: WHIZ25GCP | Enroll Now

Home / AWS / Guided Lab / Difference between SQS Visibility Timeout and Delay Queue

Difference between SQS Visibility Timeout and Delay Queue


Level: Intermediate

AWS Lambda Amazon SQS Amazon Web Services

Cloud Developer, Cloud DevOps Engineer  e 0h 23m 43s left

Storage, Serverless  End Lab

Open Console

Lab Steps Validation

Task 1: Launching Lab Environment


Lab Credentials

1. Launch the lab environment by clicking on  . Please wait until the lab User Name x
environment is provisioned. It will take less than 2 minutes to provision the lab environment. Whiz_User_62450.92113839 w
2. Once the Lab is started, you will be provided with IAM user Password x
name, Password, AccessKey and Secret Access Key. ae05551e-7986-4bd3-855b-6 w
3. Click on the  , AWS Management Console will open in a new tab.
Access Key x
4. In the AWS sign in page, the Account ID will be present by default.
AKIAUITV5QZ3GM5WS652 w
Secret Key x
Leave the Account ID as default. Do not remove or change the Account ID otherwise you
cannot proceed with the lab.
UYkpBKZES4/UPV1gA34qhIwxO w
5. Copy and paste the IAM user name and Password into AWS Console. Click on Sign in to log Support Documents
into the AWS Console.

Need help?
Note : If you face any issues, please go through FAQs and Troubleshooting for Labs.
How to use Hands on Lab
Task 2: Create an IAM Role
Troubleshooting Lab
1. Click on Services and select IAM under the Security, Identity and Compliance section.
FAQs
2. Select  Roles  in the left panel and click on Create role to create a new IAM role.

Submit Feedback Share

3. Choose     and then select  for


the role. 

4. Click on Next: Permissions button.

5. Type AmazonSQSFullAccess in the search bar and then select 

6. Click on Next: Tags.

Key : Enter Name

Value : Enter Lambda_SQS

Click on Next: Review.

7. On the Create Role Page:


https://www.whizlabs.com/labs/difference-between-sqs-visibility-timeout-and-delay-queue 1/9
6/11/22, 1:49 PM Difference between SQS Visibility Timeout and Delay Queue

 Role Name :  Enter  Lambda_sqs_fullaccess


Role description : Enter IAM Role to access SQS

Click on the Create role button.

You have successfully created the role to access sqs service.

     

Task 3: Create a SQS Queue

1. Navigate to the   menu on the top, select   under 

2. Make sure you are in the N. Virginia region.

3. Click on the Create queue button.


Pricing My Credit Points: 970
        

4. Details : 

Type : Select Standard

Name : Enter Whizlabs-sqs

        

5. Configuration : 

Visibility timeout : Enter 1 Minute

Leave everything as default.

https://www.whizlabs.com/labs/difference-between-sqs-visibility-timeout-and-delay-queue 2/9
6/11/22, 1:49 PM Difference between SQS Visibility Timeout and Delay Queue

        

6. Click on the Create queue button.

        

7. Now copy the Queue URL under Details and place it in the text editor, we will be using this while
creating the lambda function.

Task 4: Create a lambda function

1. Click on the link https://console.aws.amazon.com/lambda/home?region=us-east-


1#/functions to open Lambda console in a new tab in the browser. It is important to have both
SQS and Lambda functions opened in two tabs.

2. Make sure you are in the US East (N. Virginia) region.

3. Click on the Create a function button.

Choose  .

Function name : Enter my_sqs_Lambda

Runtime: Select Python 3.8

Permissions: Click on the  Change default execution role and choose 

Existing role: Select  Lambda_sqs_fullaccess from the dropdown list.

Click on Create function button.

https://www.whizlabs.com/labs/difference-between-sqs-visibility-timeout-and-delay-queue 3/9
6/11/22, 1:49 PM Difference between SQS Visibility Timeout and Delay Queue

5. Code section, Replace the existing code with the below

import json

import boto3
w
Copy

def lambda_handler(event, context):

    try:

        sqsClient = boto3.client("sqs", region_name="us-east-1")

        try:

            response = sqsClient.receive_message(

                QueueUrl="<your Queue URL>",

                AttributeNames=['All'],

            )

            print(response)

            return response

        except Exception as e:

            print("Get queue message failed because ", e)

    except Exception as e:

        print("Client connection to SQS failed because ", e)

6. Note: Please paste the SQS Queue URL which you copied and placed in the text editor.

7. Save the function by clicking on Deploy in the-top right corner.

8. Now click on Test  button, Event name : Enter LambdaTest and click on the Create button.

Task 5: Send a message with Visibility Timeout

1. Go to the SQS Queue browser tab.

2. Click on the Send and recieve messages button on the top right side.

3. Under Send message:

Message body : Enter Test Visibility timeout

4. Now click on the Send message button.

5. You will be able to see a similar message.

     

6. Now go to the Lambda function Browser tab.

https://www.whizlabs.com/labs/difference-between-sqs-visibility-timeout-and-delay-queue 4/9
6/11/22, 1:49 PM Difference between SQS Visibility Timeout and Delay Queue

7. Click on Test button of your function and check the lambda function execution output.

8. You will be able to see the message that you have sent in the Queue, as shown below.

        

9. Now again click on the Test button and check the lambda output.

10. You won't be able to see the message, this is because once the message is received by the
lambda function (Consumer). The visibility timeout starts, which you have set to 1 Minute.

     

11. For 1 Minute the message will not be available in the queue to be received by the consumer.
This is what visibility timeout is set.

12. Try to Test the lambda function after 1 Minute and you will be able to receive the message
again.

     

Task 6: Purge the Queue

1. Navigate to the SQS browser tab.


https://www.whizlabs.com/labs/difference-between-sqs-visibility-timeout-and-delay-queue 5/9
6/11/22, 1:49 PM Difference between SQS Visibility Timeout and Delay Queue
g Q

2. Click on the queue name on top left of the page.

     

3. Now click on Purge button.

4. Enter purge in the confirm box and click on Purge button.

5. Purge will delete all the messages present in the queue.

Task 7: Send a message with Delivery Delay

1. Click on the Send and recieve messages button on the top right side.

2. Under Send message:

Message body : Enter Test delivery delay

Delivery Delay : Enter 30 Seconds

    

3. Now click on the Send message button.

4. You will be able to see a similar message.

     

5. Now go to the Lambda function Browser tab.

6. Click on Test button of your function and check the lambda function execution output.

        

https://www.whizlabs.com/labs/difference-between-sqs-visibility-timeout-and-delay-queue 6/9
6/11/22, 1:49 PM Difference between SQS Visibility Timeout and Delay Queue

7. The message is not available, because we have added a delay to deliver the message to the
consumer (Lambda function)

8. Now wait for 30 seconds and then again click on Test button of your function and check the
lambda function execution output.

     

Task 8: Purge the Queue

1. Navigate to the SQS browser tab.

2. Click on the queue name on top left of the page.

     

3. Now click on Purge button.

4. Enter purge in the confirm box and click on Purge button.

Task 9: Validation Test

1. Once the lab steps are completed, please click on the   button
on the left side panel.

2. This will validate the resources in the AWS account and shows you whether you have
completed this lab successfully or not.

3. Sample output :

https://www.whizlabs.com/labs/difference-between-sqs-visibility-timeout-and-delay-queue 7/9
6/11/22, 1:49 PM Difference between SQS Visibility Timeout and Delay Queue

        

Task 10: Delete AWS Resources

Delete SQS Queue

1. Navigate to the   menu on the top, select 

under  .
2. Make sure you are in the N. Virginia region

3. In the left top side click on   and then click on Queues.

4. Select your SQS Queue Whizlabs-sqs and click on the Delete button.

    

5. Enter delete in the confirm box and click on Delete button.

Delete Lambda Function

1. Navigate to Lambda by clicking on the   menu


at the top, then click on   in the 
 section.
2. Make sure you are in the US East (N. Virginia) region.

https://www.whizlabs.com/labs/difference-between-sqs-visibility-timeout-and-delay-queue 8/9
6/11/22, 1:49 PM Difference between SQS Visibility Timeout and Delay Queue

3. Select the lambda function my_sqs_Lambda and click Actions and click 


 button.

     

4. Click the Delete button to confirm deletion.

Completion and Conclusion


1. Successfully created an IAM Role.

2. Successfully created a SQS queue.

3. Successfully created a Lambda function.

4. Successfully sent a message with Visibility Timeout.

5. Successfully purged the Queue.

6. Successfully sent a message with Delivery Delay.

7. Successfully purged the Queue.

End Lab
1. Sign out of the AWS Account.

2. You have successfully completed the lab.

3. Once you have completed the steps, click on   from your whizlab’s dashboard.

About Us Subscription Instructions and Guidelines FAQ’s Contact Us


a f h
© 2022, Whizlabs Education INC.

https://www.whizlabs.com/labs/difference-between-sqs-visibility-timeout-and-delay-queue 9/9

You might also like