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

杀马特。学长 韩版系。学妹 提交于 2020-12-30 04:53:32

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/48524536/can-anyone-please-tell-me-what-are-the-differences-between-pika-and-kombu-messag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!