Skip to content

Instantly share code, notes, and snippets.

<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Student</title>
</head>
<body>
<h1>Add Student</h1>
<form method="POST">
<label>Name:</label>
@scroll2learn
scroll2learn / data_consumer.py
Created March 10, 2023 06:07
Receive messages from SQS queue
import boto3
import json
import time
from sqs_url import QUEUE_URL
# Create SQS client
sqs = boto3.client('sqs')
i = 0
while i < 10000:
i = i + 1
rec_res = sqs.receive_message(
@scroll2learn
scroll2learn / data_producer.py
Created March 10, 2023 05:54
Python code to send data to SQS queue
import boto3
import json
import time
from sqs_url import QUEUE_URL
# Create SQS client
sqs = boto3.client('sqs')
with open('sample_data.json', 'r') as f:
data = json.loads(f.read())
@scroll2learn
scroll2learn / queue_status.py
Created March 10, 2023 05:52
Check the SQS queue status
import boto3
import time
from sqs_url import QUEUE_URL
sqs = boto3.client('sqs')
i = 0
while i < 100000:
i = i + 1
time.sleep(1)
response = sqs.get_queue_attributes(
@scroll2learn
scroll2learn / sample_data.json
Created March 10, 2023 05:49
Prepare the sample data
[
{
"name": "Harper Pierce",
"email": "harperpierce@thepenguinconsultingfirm.com",
"donation": 97.5
},
{
"name": "Lois Huber",
"email": "loishuber@thepenguinconsultingfirm.com",
"donation": 28.31
@scroll2learn
scroll2learn / sqs_url.py
Created March 10, 2023 04:56
Save the URL of SQS queue
QUEUE_URL = "https://queue.amazonaws.com/<Replace with your aws account id>/my-queue"
@scroll2learn
scroll2learn / create_queue.py
Created March 10, 2023 04:39
create a new SQS queue using Boto3
import boto3
# Create SQS client
sqs = boto3.client('sqs')
# Create a SQS queue
response = sqs.create_queue(QueueName='my-queue',
Attributes={'DelaySeconds': '5',
'VisibilityTimeout': '60',
'MessageRetentionPeriod': '86400'})
print(response['QueueUrl'])