MQTT event adapter is an internal event adapter that comes with WSO2 products.
Prerequisites
Follow the steps below before starting the input MQTT event adapter configuration.
- Download MQTT client library (
mqtt-client-0.4.0.jar
). - Add the file to
<PRODUCT_HOME>/repository/components/lib/
directory.
Configuring input MQTT event adapter
Follow the below steps to configure the input MQTT adapter using the management console or using a configuration file.
Using the management console
Follow the instructions below to configure input MQTT event adapter using the management console.
- Log in to product management console, and click Event Processor Configs in the Configure menu.
- Click Add Input Event Adaptor in the Input Event Adaptors menu.
- Enter details as shown in the below example.
Following values are used in the configuration above example:Event Adaptor Name: mqttInputEventAdaptor
Event Adaptor Type: mqtt
Broker Url: tcp://localhost:1883
Clean Session: true
Keep Alive: 70000
Click Add Event Adaptor.
After an adapter is successfully added, click Edit to change its configuration and redeploy it. This will open a XML-based editor allowing you to edit the event adapter configurations from the UI. Do your modifications and click Update . You can also delete it or enable statistics and tracing using the provided UI options.
Using a configuration file
Follow the instructions below to configure ActiveMQ input JMS event adapter using a configuration file.
Create a XML file with the following MQTT input event adaptor configurations.
Input event adaptor implementation must start with
<inputEventAdaptor>
as the root element.<inputEventAdaptor name="mqttInputEventAdaptor" statistics="disable" trace="disable" type="mqtt" xmlns="http://wso2.org/carbon/eventadaptormanager"> <property name="cleanSession">true</property> <property name="url">tcp://localhost:1883</property> <property name="keepAlive">70000</property> </inputEventAdaptor>
Add it in
<PRODUCT_HOME>/repository/deployment/server/inputeventadaptors/
directory.
Since hot deployment is enabled, you can simply add/remove files to deploy/undeploy to/from the server.
Configuring input MQTT event adaptor message properties
The configured input event adapters will be used in event builders. With input event adaptor message properties, event builders will be able to extract data from the incoming events to build the event streams. Following are the specific message properties of input MQTT event adapter.
- Topic : The topic that will be used to receive messages on the
mqttInputAdaptor
- Client Id : Unique client id for communication (You cannot have duplicated client IDs for same MQTT broker.)
- Input Mapping Type: The incoming event type to be mapped.