​Apache Kafka is a distributed streaming platform. It allows you to create publishers, which create data streams, and consumers, which subscribe to and ingest the data streams produced by publishers.
You can use OmniSciDB KafkaImporter C++ program to consume a topic created by running Kafka shell scripts from the command line. Follow the procedure below to use a Kafka producer to send data, and a Kafka consumer to store the data, in OmniSciDB.
This example assumes you have already installed and configured Apache Kafka. See the Kafka website.
Create a sample topic for your Kafka producer.
Run the kafka-topics.sh
script with the following arguments:
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1--partitions 1 --topic matstream
Create a file named myfile
that consists of comma-separated data. For example:
michael,1andrew,2ralph,3sandhya,4
Use omnisql
to create a table to store the stream.
create table stream1(name text, id int);
Load your file into the Kafka producer.
Create and start a producer using the following command.
cat myfile | bin/kafka-console-producer.sh --broker-list localhost:9097--topic matstream
Load the data to OmniSciDB using the Kafka console consumer and the KafkaImporter
program.
Pull the data from Kafka into the KafkaImporter
program.
/home/omnisci/build/bin/KafkaImporter stream1 omnisci -p HyperInteractive -u omnisci --port 6274 --batch 1 --brokers localhost:6283--topic matstream --group-id 1​Field Delimiter: ,Line Delimiter: \nNull String: \NInsert Batch Size: 11 Rows Inserted, 0 rows skipped.2 Rows Inserted, 0 rows skipped.3 Rows Inserted, 0 rows skipped.4 Rows Inserted, 0 rows skipped.
Verify that the data arrived using omnisql
.
omnisql> select * from stream1;name|idmichael|1andrew|2ralph|3sandhya|4