Skip to main content

sqs message listener using boto3

Project description

message-listener

This module can be used for listening to the messages from aws sqs.

Requirements

  1. install module pip install py-message-listener

Follow bellow steps for using this module

  1. Add @Listener decorator to method or function where do you want to receive the message, for that method/function add single parameter, This parameter is set whenever the message is received and method will be called and message will be passed as argument.
  2. In decorator pass queue name in destination argument
  3. set these environment variables: AWS_REGION, AWS_ACCOUNT_ID, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
  4. Added kwargs for configuring listener visibility_timeout, wait_time_seconds and max_number_of_messages
  5. poll_after_seconds this argument specify how much time to wait before requesting for the messages
  6. delete_on_exception this argument specifies , whether to delete the message if any exception occurs while processing the message
  7. To delete the message return True from the message processing method

AWS_ACCOUNT_ID this will be used for generating the queue url

Sample Code

from listener import Listener


@Listener(destination='test.fifo')
def fun(msg: str):
    print(msg)
    return True

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-message-listener-0.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_message_listener-0.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file py-message-listener-0.2.tar.gz.

File metadata

  • Download URL: py-message-listener-0.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for py-message-listener-0.2.tar.gz
Algorithm Hash digest
SHA256 8d1c56e05a2c6dd2b2c6fd87c710284b5bb17c4c8d17d93acb2ccfc77731fae9
MD5 e5e070d2bd678776fbe9c881568bccd8
BLAKE2b-256 d48549075b09e7d55d7214d96cfb1ca98ea223163c3c1ed892a95674793858f3

See more details on using hashes here.

File details

Details for the file py_message_listener-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for py_message_listener-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 811969091259e4f76c1b29dd17b7e444cfc4fdcc4efeffe06fc9a5fa6054b1fb
MD5 670299c0c7dd14246701b61c03296fd6
BLAKE2b-256 b7f5e3685fd9170ccd33005c3b70cc4079d0b961902f476d4a4edc6b9524579c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page