hono: Message mapping API does not return a failed future
Maybe I do not understand the mapper endpoint feature added recently, so please bear with me 😃 I will close the issue once my doubt is clarified 😉
According to HttpBasedMessageMapping#mapMessage API docs, the method is supposed to returned
- a
mapped messageif the device payload can be successfully mapped to anew payload typeOR - a
failed future, with a ServiceInvocationException, if the message cannot be mapped. This happens when the device registration info contains a mapper in its config but the adapter is not configured with an Endpoint corresponding to the configured mapper for the device/gateway
However, the current default implementation present with Hono does not do that. In the default impl., if a mapper is not configured for a device/gateway, or it is configured but endpoint is either missing or not configured for the adapter, then the original message is mapped as-is. No failure is returned. If this is the intended behavior, should the API docs be adapted accordingly?
If you look at where the API is used (i.e the onPublishedMessage handler of the MQTT adapter), I can see why the original message is mapped as-is instead of returning a failure (makes the caller code easier I think). IMHO, the mapper should not map all incoming MQTT messages: either it successfully maps an incoming message (if it can) or fails. In the case of a failure, the MQTT adapter can proceed to forward the message like before, ignoring the failed attempt to mapped the message.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (23 by maintainers)
Commits related to this issue
- [#2133] Improve message mapping API Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com> — committed to Alfusainey/hono by Alfusainey 4 years ago
- [#2133] Improve message mapping API Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com> — committed to Alfusainey/hono by Alfusainey 4 years ago
- [#2133] Improve message mapping API Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com> — committed to Alfusainey/hono by Alfusainey 4 years ago
- [#2133] Improve message mapping API Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com> — committed to eclipse-hono/hono by Alfusainey 4 years ago
great! Thanks @Alfusainey!
@Alfusainey I have added the 1.5.0 release to the project management website.