This is an example class for handling message queues in AWS SQS service.
- boto3
- python-environ
Use the package manager pip to install foobar.
pip3 install -r requirements
Rename .env.example file to .env .
mv .env.example .env
Then edit constants which .env file contains.
Mandatory defines:
AWS_ACCESS_KEY_ID=""
AWS_SECRET_ACCESS_KEY=""
#for region name example: us-east-1
REGION_NAME=""
Define credentials and constant variables via environ.
env = environ.Env()
environ.Env.read_env()
AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY = env("AWS_SECRET_ACCESS_KEY")
REGION_NAME = env("REGION_NAME")
QUEUE_NAME = 'MyQueue'
Initialize SQSHandler instance for handling queue.
sqs_handler = SQSHandler(
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
REGION_NAME, QUEUE_NAME)
Core methods:
#show all available queues
sqs_handler.show_all_available_queues()
#send given message
sqs_handler.send_message("Hello")
#receive available message on most top
sqs_handler.receive_message()
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.