Message mapping API does not return a failed future
See original GitHub issueMaybe 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 message
if the device payload can be successfully mapped to anew payload type
OR - 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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:23 (23 by maintainers)
Top GitHub Comments
great! Thanks @Alfusainey!
@Alfusainey I have added the 1.5.0 release to the project management website.