问题简述:
当使用RabbitMQ进行通信时,我是否需要祈祷不会出现两个独立的应用程序在同一时间使用相同的频道,以防止“broken pipe error”?(或者线程与拥有两个或更多独立应用程序有何不同?)
历史记录:
我编写了一些应用程序,其中一个(io-server)从我的其他应用程序的角度来看像是服务器,而从RabbitMQ服务器的角度来看则像是客户端。
现在,所有东西都按预期工作大约10分钟。然后,我的io-server崩溃了。以下是traceback的最后一部分:
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
我可以让我的应用程序同时发布。但是如何确保所有应用程序同步运行?我真的需要吗?