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


This sample demonstrates how to publish XML events via Kafka transport. This sample does not do any processing on the outgoing event. Events are generated using an input event file and the event simulator.


Follow the steps below before starting the output Kafka event publisher configuration. 

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

  3. Configure sample client by adding relevant jars. See Setting up Kafka for Kafka sample clients.
  4. Start the Apache ZooKeeper server with the following command: bin/ config/ You view the below logs. For more information, see Apache Kafka documentation
    logs of starting the ZooKeeper server
  5. Then start the Kafka server with the following command:  bin/ config/ You view the below logs. 
    logs of starting the Apache Kafka server

Building the sample  

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

  • An event stream with the ID
  • An event publisher named kafkaEventPublisher to fetch events from the configured receiver email address  
  • Loads the events stored in the <CEP_HOME>/samples/cep/artifacts/0068/eventsimulatorfiles/events.csv file to the event simulator.

Executing the sample

Follow the steps below to execute the sample.

  1. Open another terminal, navigate to <KAFKA_HOME>/ directory, and execute the following command to consume messages which are published from the CEP via the Kafka event publisher: bin/ --zookeeper localhost:2181 --topic sensorInfo --from-beginning

  2. Log in to the management console.

  3. Click Tools, and then click Event Simulator.
  4. Click Play on the corresponding event stream as shown below, to send the events in the <CEP_HOME>/samples/cep/artifacts/0058/eventsimulatorfiles/events.csv file to the publisher.
    simulating the sending of events to WSO2 CEP
  5. Execute the following command to view the output logs in the terminal of the Kafka server: bin/ --zookeeper localhost:2181 --topic sensorInfo --from-beginning
    You view the XML events that are published to the CEP server in the logs of the Kafka consumer terminal as shown below.
    events published from the CEPs erver
  • No labels