-
Notifications
You must be signed in to change notification settings - Fork 137
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
Challenging Task: find a way to propagate command acknowledgement to downstream applications #3585
Comments
As we already have negative acknowledgments by means of command-response messages, I could imagine having option 2 implemented - positive ack for one-way commands only, sent via a command-response message with a special Hono content-type. I would see this as something to be enabled on the one-way command message via a specific header (to be documented in the headers table here). The documentation should then point out the caveats on how a positive ack can be interpreted, like it is done in the AMQP-based Command & Control API:
|
@calohmn Thanks for your fast feedback. We will come up with a PR referencing this issue. |
…Google Pub/Sub based commands Signed-off-by: Matthias Kaemmer <[email protected]>
…Google Pub/Sub based commands Signed-off-by: Matthias Kaemmer <[email protected]>
…Google Pub/Sub based commands Signed-off-by: Matthias Kaemmer <[email protected]>
…Google Pub/Sub based commands Signed-off-by: Matthias Kaemmer <[email protected]>
Having taken a look at #3612 I would like to step back to make sure that we are on the same page regarding the use case and requirements. My understanding is, that in general, there is not need for this at all, because Hono already provides means to solve the issue, which is the Reques/Response Command where a downstream application sends an application level command to a device and the device sends back an application level response. This is completely independent from the underlying transport protocol(s) being involved. And providing this kind of abstraction has been the main goal of Hono from the very beginning. Now I also can guess where this issue is coming from: there are some devices that connect via MQTT and subscribe to a particular topic (using QoS1) on which they expect to receive a particular message which they then acknowledge using a PUBACK. I also assume that these devices cannot and/or should not be altered (anymore). However, for the sake of understanding the requirements here, can we agree that if we were able to change these devices' firmware, then the right thing to do would actually be to have them support a Request/Response Command, i.e. to not only use a PUBACK to acknowledge the command but also to publish a Response message back to Hono? |
Some comments to what you posted
How would that be different if your application would now need to wait for a positive acknowledgement? Even when using a Request/Response Command, your application would eventually need to give up (waiting for the response) and consider the exchange to have failed. This brings us to
Hono deliberately chose to not implement retries nor deferred delivery of buffered messages because the semantics of doing so would open a whole can of worms that would need to be considered per application. Thus the responsibility for implementing this lies with the application. Hono only provides means to better assess when an exchange could be considered successful or not. |
As discussed during our recent open hour meeting, your assumption is correct that this initiative is primarily intended for devices whose firmware cannot or should not be altered. If this were not be the case, than supporting the Request/Response Command would definitively be the preferred solution. Therefor I agree with your comment in the related PR #3612 that this should probably be implemented as an extension of the Request/Response Command, rather than the one-way Command. This way the adapter can send the command response on behalf of the device, for devices not capable to do it on their own. |
Yes, in both scenarios, we must establish a maximum waiting period for either the positive or negative (error) acknowledgment. However, from my point of view, the distinction lies in the average waiting times associated with each type of acknowledgment. With positive acknowledgments, we typically only have to wait a few milliseconds to receive confirmation that the message was successfully received by the device, which should be the norm. We only have to wait the full predefined waiting period in the event of a failure, which should be a rare occurrence. In contrast, with negative acknowledgments, we must wait the full duration for every successful command. Furthermore, both methods introduce an element of uncertainty. However, this uncertainty is arguably better placed in the positive acknowledgment scenario. Here, we can be confident of successful messages and only have uncertainty for failed messages (when the predefined waiting time is exceeded). For negative acknowledgments, it’s the opposite. We can never be entirely sure that a message was successfully received. |
@calohmn WDYT? |
For this type of scenario, having devices that only send confirmation on the protocol level (PUBACK for MQTT) and can't be changed, I see the usefulness in providing this acknowledgment to the downstream application, to have at least certainty there that the message has reached the device.
As pointed out by @mattkaem above, I also think the average waiting time associated with each type of acknowledgment makes a difference here, the time being shorter when the device sends a positive acknowledgement compared for example with the case that the device is busy and a timeout period has to elapse for the negative response to be sent. Coming to the implementation of this:
As also mentioned in my PR comment, I think this point is debatable. From the perspective of the device, such an Therefore, I think in the protocol adapter implementation, we should forward such |
@calohmn just to be sure:
still means that the application will send a request/response command, but based on the That would sound reasonable to me. @mattkaem Would that work for you as well? |
@sophokles73 yes |
If I understand this correctly, to trigger the adapter ack mechanism the application would need to send a command with |
FMPOV the two attributes don't need to be necessarily mutually exclusive (XOR). Both attributes could be set to true for example for scenarios where the sending application requires:
What are your thoughts @calohmn @sophokles73 ? |
My understanding of the adapter's behavior is, When an application sends a request/response command:
I currently do not see a reason why the properties would need to be used mutually exclusively. @calohmn can you provide some more insight into your thinking? |
@sophokles73 Regarding the first 3 rows in the above table, my view differs in the fields marked with (*):
On Concerning the
With
Like @mattkaem mentioned above:
So, this wouldn't be |
We mean the same thing. You seem to take the perspective of the Command Router while I tried to describe the application's view. In any case. this is the case where no special behavior is expected from Command Router/Adapter. The application waits for a response but never gets one.
Assuming that you mean
then I can live with that. |
The whole point of introducing ack-required is to let an App tell Hono that the device is not able to respond on itself. Forwarding the request/response command therefore makes no sense in this case. @mattkaem WDYT? |
I think this definitively makes sense.
That is true. However, in my opinion it is like @calohmn said:
Additionally, if I am not mistaken, this would result in
@calohmn @sophokles73 Do you see any other options or what are your thoughts? |
My understanding of what the docs intend to say is:
The whole thing had been introduced to allow the adapter and/or command router to send a (negative) response on behalf of the device to the Application when using Kafka as the messaging infrastructure. So it definitely was not meant to require that the command is being forwarded to the device under all circumstances. I therefore still do not see any problem with what I had suggested for the |
My problem with this understanding is, that it introduces a dependency on the The alternative would be: With the latter approach, the
When both |
@calohmn after a discussion during yesterday's Hono Open Hour with @mattkaem I now believe that I understand your point: if an Application sets both We should prevent this from happening and I therefore also believe that we should make @mattkaem In the API documentation we need to properly describe the two different use cases that we want to support, e.g. also providing an example flow. |
Disclaimer: We are aware that this scenario is covered by the request / response command in hono - but we still think
the acknowledgement propagation could be beneficial for downstream applications
MQTT Scenario:
In Hono the command is propagated via the command router to the mqtt adapter which forwards it to the connected device.
The standard behaviour of mqtt clients is to acknowledge the command message via puback.
Now the challenging part:
As Hono internally does know about the acknowledgement of the command message - it does not share this infromation with
downstream applications.
As a workarround we listen to the error topic and see if something goes wrong. However we cannot wait forever with
this and this is - as I said only a workarround.
As part of this issue we have seen cases where a client subscribing with QOS1 to c///req/# did
not receive the command - which also raises questions:
client applications can return a positive answer?
We see two option of implementing this:
1.) Implement the acknowledgement propagation for both oneway commands and request / response commands
Downsight - request / response commands have two ways of acknowledgement
2.) Implement the acknowledgement propagation for oneway commands only.
In this way the downstream application can benefit from the ack.
Additional Info: we have read thru this Issue here - #2273 - and think that
there were similar discussions going back and forth when implementing the Command Acknowledgement.
Please let us know your thoughts on this. Any input is welcome.
The text was updated successfully, but these errors were encountered: