快速提问:
为了防止“Broken Pipe Error”,我是否需要祈祷两个独立的应用程序在通信 RabbitMQ 时不要同时使用相同的通道?(或者线程与拥有两个或多个独立应用程序不同?)
历史:
我已经编写了一些应用程序,其中一个(io-server)从我的其他应用程序的角度来看就像一个服务器,从 RabbitMQ 服务器的角度来看它就像一个客户端。
现在,一切都按预期运行了大约 10 分钟。然后,我的 io-server 崩溃了。这是回溯的最后一部分:
File "/usr/local/lib/python2.7/dist-packages/amqp-1.4.2-py2.7.egg/amqp/transport.py", line 163, in write_frame
frame_type, channel, size, payload, 0xce,
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
error: [Errno 32] Broken pipe
这是 RabbitMQ 日志的相关部分:
=ERROR REPORT==== 31-Mar-2014::12:29:53 ===
AMQP connection <0.22183.0> (running), channel 1 - error:
{amqp_error,unexpected_frame,
"expected content header for class 60, got non content header frame instead",
'basic.publish'}
=INFO REPORT==== 31-Mar-2014::12:30:23 ===
closing AMQP connection <0.22183.0> (127.0.0.1:43367 -> 127.0.0.1:5672)
据我所知,最有希望的答案在这里:
...
So yes, RabbitMQ closes the connection due to a connection-level error
with frame interleaving.
...
* Avoid publishing on *the same* channel from multiple threads
* Synchronize publishing in your own code
我可以让我的应用程序同步发布。但是如何保证我的所有应用程序同步运行?我真的必须吗?