Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

This section contains one example for the MQTT agent.


MQTT Agent

In this workflow example for the MQTT agent

 

MQTT workflow example


The MQTT agent sends any of these 3 UDR types: Error, PublishAck or SubscribeResponse to the Analysis agent, which contains the following code:


consume {
    debug(input);
    if(instanceOf(input, MQTT.SubscribeResponse)){
        MQTT.SubscribeResponse resp = (MQTT.SubscribeResponse)input;
        MQTT.Publish pub = udrCreate(MQTT.Publish);   
        pub.qos = 1;
        pub.retain = true;
        pub.topic = "test/";
        pub.data = resp.data;
        udrRoute(pub);
    }
}

With this code, the Analysis agent will:

  • Debugs the output of the MQTT agent.
  • If the received UDR is of the SubscriberResponse type, the UDR will be populated into a SubscribeResponse type UDR called resp.
  • Create a UDR of Publish type called pub.
  • Set the qos to 1, to indicate that the message will be publish with the At Least once QoS.
  • Set retain to true.
  • Set the topic to test/
  • Populate the Data with the Data field from the resp UDR.
  • Routes the pub UDR back to the MQTT agent.


  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.