Skip to content

Receiving Binary Events via Kafka


This application demonstrates how to configure WSO2 Streaming Integrator Tooling to receive events to the SweetProductionStream via Kafka transport in Binary Format and log the events in LowProductionAlertStream to the output console.


  1. The following steps must be executed to enable WSO2 SI to receive events via the Kafka transport. Since you need to shut down the server to execute these steps, get a copy of these instructions prior to proceeding.
    1. Download the Kafka broker from here:
    2. Convert and copy the Kafka client jars from the {KafkaHome}/libs directory to the {WSO2SIHome}/libs directory as follows.
      1. Create a directory named {Source} in a preferred location in your machine and copy the following JARs to it from the {KafkaHome}/libs directory.
        • kafka_2.11-
        • kafka-clients-
        • metrics-core-2.2.0.jar
        • scala-library-2.11.8.jar
        • zkclient-0.8.jar
        • zookeeper-3.4.6.jar
      2. Create another directory named {Destination} in a preferred location in your machine.
      3. To convert all the Kafka jars you copied into the {Source} directory, issue the following command,
        • For Windows:
          {WSO2SIHome}/bin/jartobundle.bat <{Source} Directory Path> <{Destination} Directory Path>
        • For Linux:
          sh {WSO2SIHome}/bin/ <{Source} Directory Path> <{Destination} Directory Path>
      4. Add the OSGI converted kafka libs from {Destination} directory to {WSO2SIHome}/lib.
      5. Add the original Kafka libs from {Source} to {WSO2SIHome}/samples/sample-clients/lib.
      6. Navigate to {KafkaHome} and start zookeeper node using following command.
        sh bin/ config/
      7. Navigate to {KafkaHome} and start Kafka server node using following command.
        sh bin/ config/
  2. Save this sample.

Executing the Sample:

  1. Start the Siddhi application by clicking on 'Run'.
  2. If the Siddhi application starts successfully, the following messages would be shown on the console.
    * ReceiveKafkaInBinaryFormat.siddhi - Started Successfully!


If you edit this application while it's running, stop the application -> Save -> Start.

Testing the Sample:

Navigate to {WSO2SIHome}/samples/sample-clients/kafka-producer and run "ant" command as follows:

ant -DnoOfEventsToSend=5 -DtopicName=kafka_sample_topic -DisBinaryMessage=true

Viewing the Results:

Messages similar to the following would be shown on the console.

INFO {} - ReceiveKafkaInBinaryFormat : LowProductionAlertStream : Event{timestamp=1513282182570, data=["Cupcake", 1665.0], isExpired=false}


  • Stop this Siddhi application, once you are done with the execution.
  • Stop Kafka server and Zookeeper server individually by executing Ctrl+C.
@App:description('Receive events via Kafka transport in Binary format and view the output on the console')

define stream SweetProductionStream(id string, amount double);

define stream LowProductionAlertStream(id string, amount double);

from SweetProductionStream
select *
insert into LowProductionAlertStream;