Good news, no need to loop it to keep it active. I recently implemented this module and I can give you a brief breakdown of how I set it up. Also good news; you don’t need the Publish flow unless you’re trying to update Mqtt information, if you’re only ‘listening’ you can just use the Subscribe action.
Firstly, I see you’re making a ConnectionDetail object, but only adding two attributes. Check the MqttConnector module, specifically the ‘ConnectToBroker’. If you examine the java action(and supporting java code) you’ll see it needs a enum for the auth type at the very least, potentially more, as I didn’t try it while lacking attributes and used basic auth.
Secondly, you want to subscribe after you’ve connected; essentially Connect → Subscribe → Await messages. The connection step is basically to verify that your ConnectionDetail object is correctly set up.
Try using the SampleonMessage flow from the Mqtt module for the Subscribe, it’ll spit your message results into the log, or you could create a different one to store it in an object, but you’ll need some import mapping to do so.
Lastly, you’ll need to trigger your Mqtt server to send a message before you can catch it; this will vary depending on your setup. In addition, you could use a tool like MqttFx client to verify your server is sending messages, then you know where the issue is (server vs Mendix)
Final tip: you’ll need an after start-up flow to re-subscribe between shut downs if you want the subscriptions to be active on start up, otherwise they need to be re-established manually.