Setting up MQTT connection
Hi,
My understanding that in IRIS we create an Inbound Adapter that would act like a Broker (connecting to server X) then have an MQTT outbound adapter to receive those messages?
Is there a quick sample that we could user to show how to setup these two Adapters, I started with this but I couldn’t for example find EnsLib.MQTT.Adapter.Inbound

and I guess here where I can set Server X IP & port


Not familiar with MQTT, I appreciate if you could take through how to setup a MQTT inbound & outbound adaptes ?
Thanks
Comments
To set up MQTT adapters in InterSystems IRIS, follow these steps:
1. Setting Up MQTT Inbound Adapter:
Create a Business Service Class: Define a new class extending
Ens.BusinessServiceand set itsADAPTERparameter toEnsLib.MQTT.Adapter.Inbound. Implement theOnProcessInputmethod to handle received messages. Example:Class EMQTT.NewService1 Extends Ens.BusinessService { Parameter ADAPTER = "EnsLib.MQTT.Adapter.Inbound"; Method OnProcessInput(pInput As EnsLib.MQTT.Message, pOutput As %RegisteredObject) As %Status { set tsc=$$$OK // Process incoming message (pInput) Quit tsc } }Compile, Add to Production, and Configure: After creating and compiling the class, add it to your production and configure the settings such as broker URL, topic name, and credentials. You can find details about these settings under the "Settings for the MQTT Adapter" section [2].
2. Setting Up MQTT Outbound Adapter:
- Create a Business Operation Class:
Define a new class extending
Ens.BusinessOperationand set itsADAPTERparameter toEnsLib.MQTT.Adapter.Outbound. Implement the method that constructs a message and sends it using the adapter. Example:Class EMQTT.NewOperation1 Extends Ens.BusinessOperation { Parameter ADAPTER = "EnsLib.MQTT.Adapter.Outbound"; Method OnMessage(pRequest As packagename.Request, Output pResponse As packagename.Response) As %Status { set tSC=$$$OK try { set message = ##class(EnsLib.MQTT.Message).%New() set message.Topic = ..Adapter.Topic set message.StringValue = "Sample Message Data" set tSC=..Adapter.Send(message.Topic, message.StringValue) } catch e { set tSC = e.AsStatus() } Quit tSC } }
3. Use Passthrough Services:
If you need basic consumption and production of MQTT messages without complex logic, you can use the built-in passthrough services EnsLib.MQTT.Service.Passthrough and EnsLib.MQTT.Operation.Passthrough. These simplify setup by using the lower-level MQTT functionalities [3][4].
4. Additional Context on MQTT in IRIS:
InterSystems IRIS supports the MQTT protocol, with version 3.1.1 built as an OASIS standard. Its interoperability module enables seamless integrations with IoT devices leveraging MQTT brokers [3][4].
Refer to these examples and settings documentation to develop and manage inbound and outbound MQTT adapters effectively [2][3][4].
Sources: