- Java
- Tutorial
Produce Messages
To build a JAR that we can run from the command line, first run:
gradle shadowJar
And you should see the following output:
BUILD SUCCESSFUL in 1s
Run the following command to execute the producer application, which will produce some random events to the purchases
topic.
java -cp build/libs/kafka-java-getting-started-0.0.1.jar io.streamnative.developer.ProducerExample
You should see output resembling this:
10 events were produced to topic purchases
Produced event to topic purchases: key = awalther value = t-shirts
Produced event to topic purchases: key = jbernard value = alarm clock
Produced event to topic purchases: key = eabara value = book
Produced event to topic purchases: key = htanaka value = book
Produced event to topic purchases: key = jbernard value = batteries
Produced event to topic purchases: key = awalther value = book
Produced event to topic purchases: key = htanaka value = book
Produced event to topic purchases: key = sgarcia value = gift card
Produced event to topic purchases: key = sgarcia value = t-shirts
Produced event to topic purchases: key = sgarcia value = book