【问题标题】:Qpid Proton Messenger API error handlingQpid Proton Messenger API 错误处理
【发布时间】:2014-09-07 03:29:09
【问题描述】:

在使用 Python 的 Qpid Proton AMQP Messenger API 发送消息时,我正绝望地尝试处理错误。

这是一个示例消息发送会话,从交互式 Python 解释器发送到在 localhost 上运行的 Qpid 代理上不存在的队列 @9​​87654321@:

>>> 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 消息之外,工作流程看起来完全一样。在代码中无法知道消息是否进入队列。

标签: python qpid


【解决方案1】:

最后。我读到信使的属性outgoing_window 默认为0。它是跟踪的传出消息的数量。将其设置为更高的数字可以解决问题:

>>> from proton import *
>>> mng = Messenger()
>>> mng.timeout = 2000L
>>> mng.outgoing_window = 1
>>> m = Message()
>>> m.address = 'amqp://localhost/myqueue'
>>> m.subject = 'Test message'
>>> tracker = mng.put(m)
>>> repr(mng.status(tracker))
'PENDING'
>>> ret = mng.send()
LINK ERROR (amqp:not-found) Node not found: myqueue
>>> repr(mng.status(tracker))
'ABORTED'
>>> mng.stop()

现在我可以跟踪消息的状态并查看它是否已中止

【讨论】:

    猜你喜欢
    • 2018-07-12
    • 2017-10-17
    • 2016-08-06
    • 1970-01-01
    • 2016-01-13
    • 2015-03-04
    • 1970-01-01
    • 2015-09-02
    • 2017-06-09
    相关资源
    最近更新 更多