Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
451 views
in Technique[技术] by (71.8m points)

amqp - How to explicitly acknowledge or deacknowledge messages with Qpid Proton Python

I have a Qpid Proton Python MessageHandler receiving some messages which trigger some processing. How can I reject a message in case the processing fails? As far as I can tell from the API documentation, the default is auto_accept=True. However, changing this to False doesn't seem to avoid acknowledging messages as a subsequent receiver doesn't catch up with the failing message.

question from:https://stackoverflow.com/questions/65934113/how-to-explicitly-acknowledge-or-deacknowledge-messages-with-qpid-proton-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you disable auto accept, explicitly accepting or rejecting a message is your responsibility. If you do neither, the message is stuck in limbo.

Here's an example of application code that does explicit acks:

def on_message(self, event):
    try:
        process_message(event.message)
        event.delivery.update(ACCEPTED)
    except:
        event.delivery.update(REJECTED)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...