简体   繁体   English

Qpid Proton Messenger API错误处理

[英]Qpid Proton Messenger API error handling

I'm getting desperate trying to handle errors when sending messages using Qpid Proton AMQP Messenger API for Python. 使用针对Python的Qpid Proton AMQP Messenger API发送消息时,我正拼命尝试处理错误。

This is an example message sending session from the interactive Python interpreter when sending to a nonexistent queue myqueue on a Qpid broker running on localhost : 这是在localhost上运行的Qpid代理myqueue消息发送到不存在的队列myqueue时,来自交互式Python解释器的消息发送会话示例:

>>> 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()

The LINK ERROR is printed directly to stdout (or stderr) and there is no indication of the message not being delivered in the API. LINK ERROR直接打印到stdout(或stderr),并且没有指示消息未在API中传递。 The status() call returns None before the send when the message is sitting in the buffer and also after, when it was dropped. 当消息位于缓冲区中时,status()调用在发送之前返回无,在消息被丢弃后,调用也返回None。

Am I missing something? 我想念什么吗?

Using Python 2.7, Qpid Proton 0.7. 使用Python 2.7,Qpid Proton 0.7。

Finally. 最后。 I read about property outgoing_window of the messenger defaulting to 0. It's the number of tracked outgoing messages. 我阅读了有关Messenger的属性outgoing_window的信息,默认为0。它是跟踪的传出消息的数量。 Setting it to a higher number solves the problem: 将其设置为更大的数字可以解决此问题:

>>> 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()

Now I can track status of the message and see that it was ABORTED . 现在,我可以跟踪消息的状态,看看它是否已终止

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM