Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can anyone please tell me what are the differences between pika and kombu messaging library in python?

I want to use messaging library in my application to interact with rabbitmq. Can anyone please explain the differences between pika and kombu library?

like image 847
Nitesh Singh Rajput Avatar asked Jan 30 '18 15:01

Nitesh Singh Rajput


People also ask

What is Python kombu?

Kombu is an open-source messaging library available for Python which aims to make messaging as simple as possible. Kombu provides a high-level interface for the Advanced Message Queuing Protocol (AMQP), an open standard protocol for message orientation, queuing, routing, reliability, and security.

What is Pika in RabbitMQ?

Pika is a Python implementation of the AMQP 0-9-1 protocol for RabbitMQ. This tutorial guides you through installing Pika, declaring a queue, setting up a publisher to send messages to the broker's default exchange, and setting up a consumer to recieve messages from the queue.

What is PyAMQP?

PyAMQP is a Python library that lets Python clients communicate with any implementation of AMQP, including RabbitMQ.


1 Answers

Kombu and pika are two different python libraries that are fundamentally serving the same purpose: publishing and consuming messages to/from a message broker.

Kombu has a higher level of abstraction than pika. Pika only supports AMQP 0.9.1 protocol while Kombu can support other transports (such as Redis). More generally, Kombu is more feature-rich than pika. It has support for reconnection strategies, connections pooling, failover strategies, among others. Some of those features are must-haves (that you'll have to re-implement or work around if you choose to use Pika in a serious project), some other are just nice to have. The downside of this: the more complex is a library, the more you will be surprised by its behavior and the harder it will be to reason about and trace bugs. Pika's codebase is relatively small and easy to get into. On the other hand, Kombu is tailor made for Celery which is a huge project. Celery's documentation is rather good, yet Kombu's documentation is quite poor in comparison. It feels like Celery is the project intended to be exposed, not Kombu.

Under the hood, when using AMQP as transport, Kombu uses either py-amqp library or librabbitmq to send/receive/parse AMQP 0.9.1 frames. In this respect, pika would be closer to py-amqp than Kombu in term of abstraction level.

RabbitMQ is complex. Choose pika if you think that you shouldn't add complexity over features that are well encapsulated already, or if you need more control and understanding over RabbitMQ. Choose Kombu if you need a turnkey solution and don't want to reinvent the wheel (i.e. reimplement some basic features which are worth a few lines of codes most of the time). But whatever library you choose, it shouldn't dispense your from learning in depth the advantages and limitations of the underlying broker.

like image 90
user8808265 Avatar answered Sep 21 '22 21:09

user8808265