Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

yuzutech/kafka-producer

Repository files navigation

Kafka Producer

Use the Java producer API to publish records to Kafka

Usage

Clone and build the project:

$ git clone https://github.com/yuzutech/kafka-producer.git
cd kafka-producer
mvn clean package

Run:

$ java -jar kafka-producer-all.jar samples/config/connector.properties
Note

By default, this command will send the following JSON message 1000 times to a local Kafka localhost:9092. See below to configure the producer.

{
  "name": "iuzu",
  "age_year": 3,
  "race": "siberian",
  "birth_date": "20130521"
}

Configuration

connector.properties
# Kafka producer configuration (1)
bootstrap.servers=localhost:9092
acks=all
retries=0
batch.size=16384
linger.ms=1
buffer.memory=33554432
key.serializer=org.apache.kafka.common.serialization.StringSerializer
value.serializer=org.apache.kafka.common.serialization.StringSerializer

# Name of a Kafka topic.
producer.topic=lolcat

# Path to a file.
# Each line will produce a record that will be send `producer.num.records` times.
# The path is relative to the connector.properties parent directory but you can also use an absolute path.
producer.file=lolcat.json

# Number of records to send (per line).
# If your file contains 5 lines and producer.num.records = 100, you will effectively send 500 records.
producer.num.records=1000

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages