Skip to main content

An abstract interface for RabbitMQ communication

Project description

https://img.shields.io/pypi/v/b_rabbit.svg https://img.shields.io/travis/nidhaloff/b_rabbit.svg https://readthedocs.org/projects/b_rabbit/badge/?version=latest PyPI - Python Version PyPI - Wheel PyPI - Downloads PyPI - Status GitHub last commit Twitter URL https://img.shields.io/badge/$-buy%20me%20a%20coffee-ff69b4.svg?style=social

RabbitMQ without headache.

b_rabbit is a RabbitMq Interface on top of rabbitpy to make implementing RabbitMQ messaging patterns easier. It is very useful especially inside large projects, in which many boilerplate code must be written. it uses a parent wrapper class that wrap all connections and classes definitions of different messaging patterns, then using the patterns is pretty straightforward by creating instances from the parent class depending on the pattern you want to use. it uses multithreading to asynchronously orchestrate between multiple subscription and RPCs.

Features

  • it implements all RabbitMQ messaging patterns.

  • provides an easy high level API (take a look at the examples)

  • thread safe since it uses rabbitpy

  • implementation of the publish-subscribe pattern

  • implementation of the Remote procedure call pattern

  • safe message delivery

When you should use it

  • if you are having problems with other non thread safe libraries (like I did)

  • if you want to develop fast by using a high level API

  • if you don’t want to write much code and save much time

  • if you want to use multithreading

  • if you want to get started with RabbitMQ

Why you should use it

  • High level of abstraction

  • Simple syntax and readability improvement

  • Scalablity (since it uses multiple channels but only one connection)

  • Asynchronous fast messaging

  • Code reusability

Quick Usage

import the library:

from b_rabbit import BRabbit

create a parent instance which provide a global rabbitMQ connection

rabbit = BRabbit(host='localhost', port=5672)

now, just one liner to publish a message:

publisher = rabbit.EventPublisher(b_rabbit=rabbit,
                                  publisher_name='pub').publish(routing_key='testing.test',
                                                                payload='Hello from publisher')

or if you want to subscribe and listen to a certain topic:

 def callback(msg):
    # do something with the received msg from the publisher
    print(f"msg received: {msg}")

# subscribe and run a listener in a thread

subscriber = rabbit.EventSubscriber(
                                b_rabbit=rabbit,
                                routing_key='testing.test',
                                publisher_name='pub',
                                event_listener=callback).subscribe_on_thread()

Further

Take a look in the examples folder for more. b_rabbit implements also the remote procedure call (RPC) pattern

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

b_rabbit-1.1.3.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

b_rabbit-1.1.3-py2.py3-none-any.whl (8.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file b_rabbit-1.1.3.tar.gz.

File metadata

  • Download URL: b_rabbit-1.1.3.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.8

File hashes

Hashes for b_rabbit-1.1.3.tar.gz
Algorithm Hash digest
SHA256 89eb79290baf557c5afed88949fde3fb4ae62a850a6cd860ca5f71cffe36f75a
MD5 bbda5e89b1d26007065dffea2435d30c
BLAKE2b-256 0d49df4f7682c9edbae293023702fdd4a32ec8443f6971a63ea5b38992c5b9b3

See more details on using hashes here.

File details

Details for the file b_rabbit-1.1.3-py2.py3-none-any.whl.

File metadata

  • Download URL: b_rabbit-1.1.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.8

File hashes

Hashes for b_rabbit-1.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ec349f4a38b853f21d72316a45c7198f7807242de044e836153f9dd98bf4fdc8
MD5 cd28e90b8dd23c4e49ece385f0de1436
BLAKE2b-256 aae8de76236dda9efd57798435097e2b3ba02441ad6e9bc120804883a187128c

See more details on using hashes here.

Supported by

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