Prerequisites
Follow the steps below before starting this Kafka sample configurations.
Set up the prerequisites required for all samples.
- Configure WSO2 CEP by adding relevant jars to support Kafka transport.
- Configure sample client by adding relevant jars. See setting up Kafka for Kafka sample clients
- Start the Apache ZooKeeper server with the following command:
bin/zookeeper-server-start.sh config/zookeeper.properties
. You view the below logs. For more information, see Apache Kafka documentation.
- Then start the Kafka server with the following command:
bin/kafka-server-start.sh config/server.properties.
You view the below logs.
Building the sample
Start the WSO2 CEP server with the sample configuration numbered 0018. For instructions, see Starting sample CEP configurations. This sample configuration creates the following.
- An event stream with the ID
org.wso2.event.sensor.stream:1.0.0
- An event receiver named
kafkaReceiver
to fetch events from the configured receiver email address
- An event publisher named
loggerEventPublisher
to log the received messages
Executing the sample
Navigate to the <CEP_HOME>/samples/cep/producers/kafka/
directory, and execute the following Ant command using another tab in the CLI:
ant -Durl=localhost:9092 -Dtopic=sensordata -Dsn=0018
The other optional parameters that can be used in the above command are defined in the <CEP_HOME>/samples/cep/producers/kafka/build.xml
file.
This builds the Kafka client and publishes the JSON events in the <CEP_HOME>/samples/cep/artifacts/0018/sensordata.txt
file to the
kafkaReceiver
endpoint. You can view the details of the events that are sent as shown below.
You view the CEP server receiving the JSON events in the logs of it in the CLI as shown below.