Follow the procedure below to complete the prerequisites needed to execute this sample.
Set up the prerequisites required for all samples.
- Configure WSO2 DAS 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. The logs shown in the screenshot below are displayed. For more information, see Apache Kafka documentation.
- Start the Kafka server with the following command.
The following logs are displayed.
Building the sample
Start the WSO2 DAS 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
- An event receiver named
kafkaReceiverto fetch events from the configured receiver email address.
- An event publisher named
loggerEventPublisherto log the received messages.
Executing the sample
Navigate to the
<DAS_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
This builds the Kafka client and publishes the JSON events in the
<DAS_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.
The JSON events received by the DAS server are logged in the CLI as shown below.