Skip to main content

Rabbit MQ Wrapper

Create a class to rapid implementation of rabbitmq on your project
If you use or like the project, click Star and Watch to generate metrics and i evaluate project continuity.
Obs: Notes this implementatio use pika as a basis.

Install:

pip install rabbitmq-wrapper

Usage:

  1. Import RabbitWrapper Class:

    from rabbitmq_wrapper import RabbitWrapper
    
  2. Create a configuration dict:

    {
       'ENABLED': True,
       'USE_EXCHANGE': '',
    
       # QUEUES
       'DEFAULT_QUEUE': 'my_queue',
       'DEADLETTER_QUEUE': 'my_queue_deadletter',  # default is setted to f"DEFAULT_QUEUE_deadletter"
       'ALLOWED_QUEUES': ['my_queue', 'my_queue_deadletter'],  # default is [DEFAULT_QUEUE, DEADLETTER_QUEUE]
    
       # CONNECTION
       'CONNECTION': {
          # see all parameters on https://pika.readthedocs.io/en/stable/modules/parameters.html#connectionparameters, https://pika.readthedocs.io/en/stable/modules/credentials.html#module-pika.credentials
          'HOST': '',
          'PORT': '',
          'USERNAME': '',
          'PASSWORD': ''
       },
       # if your prefer, you can use url connection
       'CONNECTION': {
          'URL': 'amqp://',
       }
    
       # Consumers
       'CONSUMERS': [
          # See all parameters on https://pika.readthedocs.io/en/stable/modules/channel.html#pika.channel.Channel.basic_consume 
          # Obs the param "on_message_callback" is replaced by callback and receive string with callback function path
          {'queue': 'email_service', 'callback': 'app.callbacks.MyReceiver', 'auto_ack': False}
       ]
    }
    
  3. Instance with settings

    RabbitWrapper(config={ ... })
    # or if your use django, you can put config on settings.py, and pass a name to instance
    RabbitWrapper(name=MyCustomConfig)
    # in settings.py:
    RABBIT_MyCustomConfig = { ... }
    
  4. Use Message Receive Wrapper Class:

    from rabbitmq_wrapper import CallbackWrapper
    
    class MyReceiver(CallbackWrapper):
       NAME = ''  # Name used to instance RabbitWrapper or None
       CONFIG = None  # Config used to instance RabbitWrapper or None
       
       def consume_data(self, raw_msg):
          # Your logic here.
          self.msg_ack()
    
    

Others

  1. See custom methods on CallbackWrapper:

    1. Message ACK
    self.msg_ack()
    
    1. Parse data to json
    # Obs: Name or Config in class params needed to use param deadletter_on_error
    self.msg_json_parser(data={}, deadletter_on_error=False, ack_on_error=False)
    
    1. Resend msg to queue
    # Obs: Name or Config in class params needed to use this
    self.msg_resend(self, data, queue=None, json=True) # params: data (data to resend), queue (queue to resend), json (parse data to json).
    
    1. Move msg to deadletter
    # Obs: Name or Config in class params needed to use this
    self.msg_deadletter(self, data, queue=None, json=True) # params: (data to move), queue (queue to move), json (parse data to json)
    

Metadata

Release files for rabbitmq-wrapper 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rabbitmq-wrapper 1.1.1
File Size Uploaded Provenance Actions
rabbitmq-wrapper-1.1.1.tar.gz 6.1 kB Without provenance Details for rabbitmq-wrapper-1.1.1.tar.gz

Release files / rabbitmq-wrapper-1.1.1.tar.gz

Download URL rabbitmq-wrapper-1.1.1.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
39b51deaf66d08f5857f7aa61d20dbdb7f10e6e95a966acbd4aa7550dc5d1e7a
BLAKE2b-256 checksum
How to use checksums
f584e8466e4a9f7c6b466d568cd17a7e428faa0e2683cbc93d2ccc5b6a6d172d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

Security for rabbitmq-wrapper 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page