Receiving Binary Events via Kafka¶
Purpose:¶
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.
Prerequisites:¶
- 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.
- Download the Kafka broker from here: https://archive.apache.org/dist/kafka/0.10.0.0/kafka_2.11-0.10.0.0.tgz.
- Convert and copy the Kafka client jars from the
{KafkaHome}/libs
directory to the{WSO2SIHome}/libs
directory as follows.- 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-0.10.0.0.jar
- kafka-clients-0.10.0.0.jar
- metrics-core-2.2.0.jar
- scala-library-2.11.8.jar
- zkclient-0.8.jar
- zookeeper-3.4.6.jar
- Create another directory named
{Destination}
in a preferred location in your machine. - To convert all the Kafka jars you copied into the
{Source}
directory, issue the following command,- For Windows:
- For Linux:
- Add the OSGI converted kafka libs from
{Destination}
directory to{WSO2SIHome}/lib
. - Add the original Kafka libs from
{Source}
to{WSO2SIHome}/samples/sample-clients/lib
. - Navigate to
{KafkaHome}
and start zookeeper node using following command. - Navigate to
{KafkaHome}
and start Kafka server node using following command.
- Create a directory named
- Save this sample.
Executing the Sample:¶
- Start the Siddhi application by clicking on 'Run'.
- If the Siddhi application starts successfully, the following messages would be shown on the console.
Notes:¶
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:
Viewing the Results:¶
Messages similar to the following would be shown on the console.
INFO {io.siddhi.core.stream.output.sink.LogSink} - ReceiveKafkaInBinaryFormat : LowProductionAlertStream : Event{timestamp=1513282182570, data=["Cupcake", 1665.0], isExpired=false}
Note:¶
- Stop this Siddhi application, once you are done with the execution.
- Stop Kafka server and Zookeeper server individually by executing Ctrl+C.
@App:name("ReceiveKafkaInBinaryFormat")
@App:description('Receive events via Kafka transport in Binary format and view the output on the console')
@source(type='kafka',
topic.list='kafka_sample_topic',
partition.no.list='0',
threading.option='single.thread',
group.id='group',
is.binary.message='true',
bootstrap.servers='localhost:9092',
@map(type='binary'))
define stream SweetProductionStream(id string, amount double);
@sink(type='log')
define stream LowProductionAlertStream(id string, amount double);
@info(name='query1')
from SweetProductionStream
select *
insert into LowProductionAlertStream;