WSO2 Complex Event Processor is succeeded by WSO2 Stream Processor. To view the latest documentation for WSO2 SP, see WSO2 Stream Processor Documentation.
||
Skip to end of metadata
Go to start of metadata

Prerequisites

Follow the steps below before starting this MQTT sample configurations.

  1. Set up the prerequisites required for all samples
  2. Configure WSO2 CEP by adding relevant jars to support MQTT transport.

  3. Configure sample client by adding relevant jars. See setting up MQTT for MQTT sample clients.
  4. Start the MQTT-supported server. (E.g. Mosquitto)

Building the sample 

Start the WSO2 CEP server with the sample configuration numbered 0016. For instructions, see Starting sample CEP configurations. This sample configuration creates the following.

  • An event stream with the ID org.wso2.event.sensor.stream
  • An event receiver named mqttEventReceiver to fetch events from the configured MQTT server
  • An event publisher named loggerEventPublisher  to log the received messages

Executing the sample 

After you view the message on successful connection to the MQTT-supported server on the WSO2 CEP logs in the CLI, navigate to the <CEP_HOME>/samples/cep/producers/mqtt/ directory, and execute the following Ant command using another tab in the CLI:  ant -Durl=tcp://localhost:1883 -Dtopic=sensordata -Dsn=0016

Replace the value of the Durl parameter in the above command with your MQTT broker URL accordingly. The other optional parameters that can be used in the above command are defined in the <CEP_HOME>/samples/cep/producers/mqtt/build.xml file.

This builds the MQTT client and publishes the events in the  <CEP_HOME>/samples/cep/artifacts/0016/sensordata.txt file to the mqttEventReceiver endpoint. You view the details of the events that are sent as shown below.

events produced and published to the MQTT broker

You view the CEP server receiving the JSON events in the logs of it in the CLI as shown below.

events received by WSO2 CEP via MQTT transport

 

  • No labels