3

我正在使用 pika 0.9.13 编写一些 python 代码来连接到 RabbitMQ。我正在创建许多子进程(可能有 1000 个),并希望每个进程都能够发送到 RabbitMQ。仔细阅读,似乎最好的方法是创建一个连接,然后在该连接中创建通道。

任何人都可以建议如何最好地做到这一点?通常,代码如下所示:-

from multiprocessing import Process

def f(connection):
    # pass the pika connection somehow ...
    # create the channel ...
    channel = connection.channel()
    # .... rest of process code

if __name__ == '__main__':
    #
    # pika code here to establish the MQ connection ...
    # connection = ....

    p = Process(target=f, args=(connection,))
    p.start()

我应该使用什么类型的适配器(BlockingConnection?)...

提前致谢 !

4

0 回答 0