Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom ACK function, check handler function status #396

Closed
mtojek opened this issue Jan 16, 2020 · 3 comments
Closed

Support custom ACK function, check handler function status #396

mtojek opened this issue Jan 16, 2020 · 3 comments

Comments

@mtojek
Copy link

mtojek commented Jan 16, 2020

Hi,

the current implementation of the paho.mqtt.golang acknowledges incoming messages once they're received, just after calling handler function.
If the handler execution fails, the message shouldn't be acknowledged but repeated.

I wish to see two features:

  1. Pass/define a custom Ack() function - could be a wrapper, a decorator pattern, etc.
  2. Call the Ack() method if only the handler function returns non-error result.

Best,
Marcin

@tonygunter
Copy link

I consume my messages then pass them off on a channel to my workers as mqtt.Message, which implements Ack(). However, the code inside router.go executes Ack() which wraps a sync.once.Do function. So exposing Ack() this way literally does nothing because it's already been executed inside router.go inside the matchAndDispatch function.

@MattBrittan
Copy link
Contributor

As per @alsm comments on #459 this functionality is by design:

This is an interesting one, because by the spec the original behaviour is correct. Once the client library has successfully received the message it should acknowledge it, the resend mechanism isn't designed as a feature to be used by applications, it's to ensure that messages successfully pass the network.

Please feel free to reopen if you disagree but its not something that we are likely to implement (pull requests would be considered but given the above I'm not sure this would be a good idea).

@bconway
Copy link

bconway commented Feb 6, 2021

IMO having the option to manually ACK a message is important for failure handling in a distributed system.

Additionally, this functionality already exists in the Java (V5?) client (https://github.com/eclipse/paho.mqtt.java/blob/master/org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/client/IMqttAsyncClient.java#L823), so this is not new ground for Paho MQTT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants