Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
446 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 Answer

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...