谁能告诉我python中的pika和kombu消息传递库有什么区别? [英] Can anyone please tell me what are the differences between pika and kombu messaging library in python?

查看:204
本文介绍了谁能告诉我python中的pika和kombu消息传递库有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中使用消息传递库与Rabbitmq进行交互.谁能解释一下pika和kombu库之间的区别?

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

推荐答案

Kombu和pika是两个不同的python库,它们在根本上具有相同的用途:将消息发布到消息代理和从消息代理使用消息.

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具有比pika更高的抽象级别.Pika仅支持AMQP 0.9.1协议,而Kombu可以支持其他传输(例如Redis).一般而言,Kombu比pika具有更多功能.它支持重新连接策略,连接池,故障转移策略等.其中一些功能是必备功能(如果您选择在严肃的项目中使用Pika,则必须重新实现或解决),而其他功能则很好.缺点是:库越复杂,您对其行为的惊讶就越多,推理和跟踪错误的难度就越大.Pika的代码库相对较小,易于理解.另一方面,Kombu是为 Celery 量身定制的,这是一个巨大的项目.Celery的文档相当不错,但与之相比,Kombu的文档却很差.感觉像Celery是要公开的项目,而不是Kombu.

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.

在后台,使用AMQP进行传输时,Kombu使用 py-amqp 库或 librabbitmq 发送/接收/解析AMQP 0.9.1帧.在这方面,就抽象级别而言,皮卡比Kombu更接近 py-amqp .

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很复杂.如果您认为不应在已经很好封装的功能上增加复杂性,或者需要对RabbitMQ进行更多控制和了解,请选择pika.如果您需要一揽子解决方案并且不想重新发明轮子(即重新实现一些基本功能,这些功能通常需要花费几行代码),请选择Kombu.但是无论您选择哪种库,都不应从深度学习基础经纪人的优势和局限性中分散精力.

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.

这篇关于谁能告诉我python中的pika和kombu消息传递库有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆