Skip to content

Ack should be sent after retry logic completes in MQTT binding #4101

@patrickheinigercsa

Description

@patrickheinigercsa

Currently, the MQTT binding in Dapr only acknowledges (mqttMsg.Ack()) messages after successful processing by the handler. This behavior can lead to repeated message delivery by the broker when the handler fails after all retries, causing potential infinite loops and unnecessary load.

Expected Behavior

  • The message should be acknowledged after the retry logic completes, regardless of success or failure.

Actual Behavior

  • mqttMsg.Ack() is only called on success.
    When retries fail, the message is never acknowledged, causing repeated delivery by the broker.

Steps to Reproduce the Problem

  • Configure MQTT binding with:
    "it is QoS: 1"
    CleanSession: true
    retain: false
    backOffMaxRetries: 0

  • Simulate a handler failure (e.g., return an error).

  • Observe that the message is retried indefinitely by the broker (I used a VerneMQ MQTT Brocker)

Proposed Solution

Move mqttMsg.Ack() outside the retry logic so it is always called after retries finish:

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions