[Python] How to properly signal message redelivery in ActiveMQ Artemis using Qpid Proton...

Discussão em 'Python' iniciado por Stack, Abril 6, 2025.

  1. Stack

    Stack Membro Participativo

    Thanks for helping!!! I'm new to Artemis, but got really surprised by it's potencial!

    I'm working with ActiveMQ Artemis and a Python client built with Qpid Proton (version 0.39.0). I'm trying to understand how to reject or release a message in Proton Python such that Artemis attempts redelivery, respecting the <max-delivery-attempts> setting configured in broker.xml.

    Here’s the context:

    • Artemis version: 2.40.0 (Docker)
    • Qpid Proton Python version: 0.39.0
    • Python client: Consumes messages using proton.handlers.MessagingHandler
    • Expected behavior: If the client can’t process a message (e.g. internal error), the client should signal Artemis to retry the delivery. After the configured number of retries (max-delivery-attempts), Artemis should move the message to the DLQ.
    broker.xml relevant section:


    <address-setting match="#">
    <max-delivery-attempts>5</max-delivery-attempts>
    <redelivery-delay>5000</redelivery-delay>
    <dead-letter-address>DLQ</dead-letter-address>
    <auto-create-dead-letter-resources>true</auto-create-dead-letter-resources>
    <dead-letter-queue-suffix>.DLQ</dead-letter-queue-suffix>
    </address-setting>

    Python client logic:


    In on_message, we release the message when HTTP callback fails:

    self.release(event.delivery, delivered=True)


    We also tried:

    self.settle(event.delivery, state=Delivery.RELEASED)


    But neither seemed to make Artemis increment the delivery count. Artemis keeps delivering the same message infinitely and never moves it to the DLQ.

    We also tried adding this (suggested in the Artemis docs), but Artemis failed to start:

    <persist-delivery-count-before-delivery>true</persist-delivery-count-before-delivery>

    Question:


    What’s the correct way to release or reject a message in Qpid Proton Python so that Artemis:

    1. Counts it as a failed delivery attempt, and
    2. Eventually sends it to the DLQ after max-delivery-attempts?

    Thanks a lot again!!

    Continue reading...

Compartilhe esta Página