Apama 10.15.0 | Connecting Apama Applications to External Components | Standard Connectivity Plug-ins | The MQTT Transport Connectivity Plug-in | Using MQTT connectivity from EPL
 
Using MQTT connectivity from EPL
The MQTT transport can either subscribe to or send to a particular topic, depending on whether your EPL is subscribing to or sending to a particular channel.
In EPL, in order to receive an MQTT message, you just need to subscribe to an MQTT topic with the appropriate prefix. For example:
monitor.subscribe("mqtt:topic_a");
on all A() as a {
print a.toString();
}
To send an Apama event to the MQTT broker, you just need to use the send...to statement to deliver the event to the MQTT topic. For example:
send A("hello world") to "mqtt:topic_a";
As with all connectivity plug-ins, the EPL application is responsible for telling the system when it is ready to start receiving events with onApplicationInitialized. See also Sending and receiving events with connectivity plug-ins.
The samples/connectivity_plugin/application/genericsendreceive directory of your Apama installation includes a simple sample which provides an easy way to get started with sending and receiving messages to or from any connectivity plug-in. For more information, see the README.txt file in the above directory and Sending and receiving events with connectivity plug-ins.