A simple Python SQS listener
Project description
##AWS SQS Listener
This package takes care of the boilerplate involved in creating an SQS listening agent.
###Installation
`pip install `
###Usage
Using the package is very straightforward - just inherit from the `SqsListener` class and implement the
`handle_message()` method.
Here is a basic code sample:
__Standard Listener__
`
from sqs_listener import SqsListener
class MyListener(SqsListener):
def handle_message(self, body, attributes, messages_attributes):
run_my_function(body['param1'], body['param2']
listener = MyListener('my-message-queue', 'my-error-queue')
listener.listen()
`
__Error Listener__
`
from sqs_listener import SqsListener
class MyErrorListener(SqsListener):
def handle_message(self, body, attributes, messages_attributes):
save_to_log(body['exception_type'], body['error_message']
error_listener = MyErrorListener('my-error-queue')
error_listener.listen()
`
__Notes__
+ The environment variable `AWS_ACCOUNT_ID` must be set, in addition to the environment having valid AWS
credentials (via environment variables or a credentials file)
+ For both the main queue and the error queue, if the queue doesn't exist (in the specified region), it will be created at runtime.
+
###Upcoming Features
Post an issue with a suggestion for a feature, and I'll see what I can do!
This package takes care of the boilerplate involved in creating an SQS listening agent.
###Installation
`pip install `
###Usage
Using the package is very straightforward - just inherit from the `SqsListener` class and implement the
`handle_message()` method.
Here is a basic code sample:
__Standard Listener__
`
from sqs_listener import SqsListener
class MyListener(SqsListener):
def handle_message(self, body, attributes, messages_attributes):
run_my_function(body['param1'], body['param2']
listener = MyListener('my-message-queue', 'my-error-queue')
listener.listen()
`
__Error Listener__
`
from sqs_listener import SqsListener
class MyErrorListener(SqsListener):
def handle_message(self, body, attributes, messages_attributes):
save_to_log(body['exception_type'], body['error_message']
error_listener = MyErrorListener('my-error-queue')
error_listener.listen()
`
__Notes__
+ The environment variable `AWS_ACCOUNT_ID` must be set, in addition to the environment having valid AWS
credentials (via environment variables or a credentials file)
+ For both the main queue and the error queue, if the queue doesn't exist (in the specified region), it will be created at runtime.
+
###Upcoming Features
Post an issue with a suggestion for a feature, and I'll see what I can do!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for pySqsListener-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1a33fe002c017552db9ddeafefe28e26aadc58b1164f62921829499a06676b6 |
|
MD5 | 13aa3795896b5b4498b929d5d03cef10 |
|
BLAKE2b-256 | 7a3d2e5cf106183a6bbcef320d40a8e0e3027179c2d586a945ff575a50ef0f3c |