This repository contains three .js scripts that can be used to test the production of records into a Kafka cluster.
-
producer.jsis the simplest script. Run it to test the production of one record into a cluster. Sample usage:node producer.js stocks ko 125. The arguments passed represent the Kafka topic, the record key, and the record value. -
batch.jsproduces a one-time batch of records into a cluster. Sample usage:node batch.js stocks 1000. Here, the arguments represent the topic and the number of records. The key will be a random number between 1 and 10, and the value will be a combination of the topic, time in milliseconds, and record number as it's created in the program. -
interval.jsproduces a specified number of records per second into the cluster. Sample usage:node interval.js stocks 10. The arguments here represent the Kafka topic and the number of records you want to producer per second.
Be sure to include a .env file with the following environmental variables:
CLIENT=
BROKERS=
KAFKA_USERNAME=
KAFKA_PASSWORD=
SECURITY=