Skip to main content

An abstract interface for RabbitMQ communication

Project description

b-rabbit-icon PyPI - Python Version PyPI - Wheel Twitter URL

RabbitMQ without headache.

b-rabbit is a RabbitMq client library that aims to make interfacing with RabbitMQ easier. It is very useful especially inside large projects, in which many boilerplate code must be written.

I started this project when I was working on a large microservices-based project in a large team. I decided to open-source the project afterwards.


  • it implements all RabbitMQ messaging patterns.

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

  • thread safe

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

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,
                                                                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(

Advanced Usage using RPC

  • task requester

from b_rabbit import BRabbit

def taskResponseListener(body):
    print('Task Response received')

rabbit = BRabbit(host='localhost', port=5672)
taskRequesterSynchron = rabbit.TaskRequesterSynchron(b_rabbit=rabbit,

taskRequesterSynchron.request_task('msg from requester')
  • task responser (server)

from b_rabbit import BRabbit
import time

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

def taskListener(server, body):
    print('Task Request received')
    server.send_return(payload="return this value to requester")

taskExecuter = rabbit.TaskExecutor(b_rabbit=rabbit,


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.2.5.tar.gz (17.2 kB view hashes)

Uploaded Source

Built Distribution

b_rabbit-1.2.5-py2.py3-none-any.whl (9.3 kB view hashes)

Uploaded Python 2 Python 3

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