【发布时间】:2014-09-07 03:29:09
【问题描述】:
在使用 Python 的 Qpid Proton AMQP Messenger API 发送消息时,我正绝望地尝试处理错误。
这是一个示例消息发送会话,从交互式 Python 解释器发送到在 localhost 上运行的 Qpid 代理上不存在的队列 @987654321@:
>>> from proton import *
>>> mng = Messenger()
>>> mng.timeout = 2000L
>>> m = Message()
>>> m.address = 'amqp://localhost/myqueue'
>>> m.subject = 'Test message'
>>> tracker = mng.put(m)
>>> repr(mng.status(tracker)) # status before send
'None'
>>> ret = mng.send() # send unconditionally returns None
LINK ERROR (amqp:not-found) Node not found: myqueue
>>> repr(mng.status(tracker)) # status after send
'None'
>>> mng.stop()
LINK ERROR 直接打印到 stdout(或 stderr),并且没有迹象表明消息未在 API 中传递。当消息位于缓冲区中时,status() 调用在发送之前和之后,当它被丢弃时返回 None。
我错过了什么吗?
使用 Python 2.7,Qpid Proton 0.7。
【问题讨论】:
-
我只是补充一点,当队列确实存在并且消息成功存储时,除了 LINK ERROR 消息之外,工作流程看起来完全一样。在代码中无法知道消息是否进入队列。