我的客户正在使用qpid-cpp-broker进行AMQP消息传递。我们的应用程序基于Python 3构建,因此我无法使用Python Qpid消息传递API(仅支持python 2.7)。
我正在尝试使用py-amqp将AMQP发送到qpid-cpp-broker,它不起作用。
import amqp
# connect to server
lConnection = amqp.Connection(host="172.17.0.2:5672", userid="", password="", virtual_host="/", insist=False)
lConnection.connect()
lChannel = lConnection.channel()
# Create a message
lMessage = amqp.Message("Test message!")
# Send message as persistant. This means it will survive a reboot.
lMessage.properties["delivery_mode"] = 2
# publish the message on the exchange
lChannel.basic_publish(lMessage, exchange="myExchange", routing_key="Test")
# Close connection
lChannel.close()
lConnection.close()
它给出以下错误:
Traceback (most recent call last):
File "sample.py", line 6, in <module>
lConnection.connect()
File "/opt/app/py-amqp/amqp/connection.py", line 308, in connect
self.drain_events(timeout=self.connect_timeout)
File "/opt/app/py-amqp/amqp/connection.py", line 491, in drain_events
while not self.blocking_read(timeout):
File "/opt/app/py-amqp/amqp/connection.py", line 496, in blocking_read
frame = self.transport.read_frame()
File "/opt/app/py-amqp/amqp/transport.py", line 253, in read_frame
payload = read(size)
File "/opt/app/py-amqp/amqp/transport.py", line 426, in _read
raise IOError('Socket closed')
OSError: Socket closed
我有一个问题,