Simple XML generator to Kafka. The project reads an .xml with special tags to generate random messages in string format. XMLKafkaGenerator is built for 0.10.0 version, if you want to play with another version you would have to change the version in pom and surely it will work
Unix:
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic xmltest
git clone https://github.com/jeff1191/XMLKafkaGenerator
cd XMLKafkaGenerator; mvn package
mv target/XMLKafkaGeneratorApp ~; cd ~/XMLKafkaGeneratorApp
java -jar XMLKafkaGenerator-v1.0-SNAPSHOT.jar example.xml application.conf
Windows OS:
bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic xmltest
git clone https://github.com/jeff1191/XMLKafkaGenerator
cd XMLKafkaGenerator & mvn package
move target\XMLKafkaGeneratorApp %USERPROFILE% & cd %USERPROFILE%\XMLKafkaGeneratorApp
java -jar XMLKafkaGenerator-v1.0-SNAPSHOT.jar example.xml application.conf
You can check messages using kafka-console-consumer.
There is a config file(config.json)that you can modify depending on what you want, moreover it includes an example(example.xml)
application.conf:
broker= "localhost"
port= 9092
topic= "xmltest"
frecuency= 5
delay=1000
date_format="yyyy-MM-dd HH=mm=ss"
date_format is used only for timestamp function
use frequency=-1 if you want to generate a infinite streaming using random data
example.xml:
<breakfast_menu>
<food>
<name>##RANDOM_STRING(Belgian Waffles, Strawberry Belgian Waffles, Homestyle Breakfast, French Toast)##</name>
<price>##RANDOM_DOUBLE(2.2, 5.5)##</price>
<description>whatever...</description>
<calories>##RANDOM_INT(200, 800)##</calories>
</food>
</breakfast_menu>
Function |
---|
##RANDOM_INT(x,y)## |
##RANDOM_DOUBLE(x,y)## |
##RANDOM_STRING(x,y,z,..)## |
##RANDOM_BOOLEAN()## |
##TIMESTAMP()## |