Creating Kafka topics to stream data
In the previous recipe, we orchestrated our Kafka broker. The next step is obviously putting Kafka to action. In order to do that, we need some topics to work with. In this recipe, we will create some topics and will also learn how to produce and consume messages. Exchanging messages can be done in two ways: scripts and Java programs. We will be learning the Java way.
Getting ready
In this recipe, we will be using the same Kafka topics script to create topics:
Open a new terminal shell and navigate to the directory where you have Kafka installed.
Let's create a new topic called
geolocations
. We will then write a basic standalone producer program that will produce geolocations for this topic. We will integrate a consumer with our geolocation application that will consume all messages produced by our standalone producer.So now, our geolocation application will have two modes in which you can store geolocations: synchronous HTTP mode and asynchronous mode using...