Weak acknowledgments to decouple signal publishers and subscribers
Motivation
Ditto 1.2.0 introduced at-least-once delivery via
acknowledgement requests.
It increased coupling between the publisher and the subscriber of signals in that the subscriber is no longer at the
liberty to filter for signals it is interested in. Instead, the subscriber must consume all signals in order to
fulfill acknowledgement requests and prevent endless redelivery.
To combat the problem,
Ditto 1.4.0 made acknowledgement labels unique and introduced the requirement
to manage declared acknowledgements, identifying of each
subscriber.
It is now possible for Ditto to issue
weak acknowledgements on behalf of the subscriber
whenever it decides to not consume a signal. That allows subscribers to configure RQL and namespace filters freely
without causing any futile redelivery.
What it is
A weak acknowledgement is issued by Ditto for any
acknowledgement request that will not be fulfilled now or ever without
configuration change.
A weak acknowledgement is identified by the header ditto-weak-ack: true
.
The status code of weak acknowledgements is 200 OK
; it signifies that any redelivery is not to be made on their
account.
A weak acknowledgement may look like this in Ditto protocol:
{
"topic": "com.acme/xdk_53/things/twin/acks/my-mqtt-connection:my-mqtt-topic",
"headers": {
"ditto-weak-ack": true
},
"path": "/",
"value": "Acknowledgement was issued automatically, because the subscriber is not authorized to receive the signal.",
"status": 200
}
How it works
Since Ditto 1.4.0, subscribers of twin events or live signals are required to declare unique acknowledgement labels
they are allowed to send. The labels of acknowledgement requests are then identifying the intended subscribers.
If the intended subscriber exists but does not receive the signal for non-transient reasons, Ditto issues
a weak acknowledgement for that subscriber.
Such reasons may be:
- The intended subscriber is not authorized to receive the signal by policy;
- The intended subscriber did not subscribe for the signal type (twin event, live command, live event or live message);
- The intended subscriber filtered the signal out by its namespace or RQL filter;
- The intended subscriber dropped the signal because its payload mapper produced nothing.
Limitation
The distributed nature of cluster pub/sub means that weak acknowledgements are not always issued correctly.
They are only eventually correct in the sense that some time after a change to the publisher-subscriber pair,
the issued weak acknowledgements will reflect the change.
Such changes include:
- Opening and closing of Websocket or other connections acting as the subscriber;
- Subscribing and unsubscribing for different signal types via Websocket;
- Modification of connections via the connectivity API;
- Migration of a connection from one Ditto cluster member to another due to load balancing.
Feedback?
Please get in touch if you have feedback or questions towards this new concept of weak acknowledgements.
–
The Eclipse Ditto team