IoT Edge module routing

mpoeckl 161 Reputation points Microsoft Employee
2020-08-24T13:17:52.663+00:00

Is it possible to route an output of an edge module into the input of the very same module (loop a message into the same module)?

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
534 questions
{count} votes

Accepted answer
  1. Sander van de Velde 28,311 Reputation points MVP
    2020-08-25T13:53:05.04+00:00

    Let's do an experiment.

    I created this VM running iot edge. I added the svelde/iot-edge-echo:2.0.1-amd64 module with an input and an output (what is coming in, is also send out):

    20187-image.png

    I added this route:

    FROM /messages/modules/echo/outputs/output1 INTO BrokeredEndpoint("/modules/echo/inputs/input1")

    So the outcoming echo module messages go into the echo module.

    Please do accept helpful posts as accepted answer so that it can help others within the community with similar issues.

    Now I only have to send one message to the echo module. We do this with the svelde/iot-edge-one-message:0.0.1-amd64 module.

    This 'one' module sends one message to 'output1' on restart of the module.

    So I added to modules, the 'one' module and the 'echo' module and this extra route:

    FROM /messages/modules/one/outputs/output1 INTO BrokeredEndpoint("/modules/echo/inputs/input1")

    I now restart the 'one module'.

    20225-image.png

    The message is sent after the restart.

    The message arrives at the echo module:

    20226-image.png

    But I see no actual resend of the same message over and over. So it seems the routing is limited to only other modules.

    To prove this, I added a second echo module.

    So the routing goes:

    FROM /messages/modules/one/outputs/output1 INTO BrokeredEndpoint("/modules/echo/inputs/input1")
    FROM /messages/modules/echo/outputs/output1 INTO BrokeredEndpoint("/modules/echo2/inputs/input1")
    FROM /messages/modules/echo2/outputs/output1 INTO BrokeredEndpoint("/modules/echo/inputs/input1")

    This time we see the infinite loop:

    20208-image.png

    Conclusion: Routing is protected against sending a message to itself. But you can fool it by putting a (the same) module in between.

    6 people found this answer helpful.

0 additional answers

Sort by: Most helpful