From the course: Apache Kafka Essential Training: Getting Started (2021)

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Publishing with keys

Publishing with keys

From the course: Apache Kafka Essential Training: Getting Started (2021)

Start my 1-month free trial

Publishing with keys

- [Instructor] In this video, let's use the console producer to publish some messages with keys for the calfcard.learning.orders topic. The command for publishing is the same as we discussed in chapter three, except for the topic name. In order to publish data with keys, we will use the colon operator to separate the key and the value. To specify this, we use two properties. The parse.key=true property tells the producer to read the key also. Key.separator is used to specify the separator character between the key and the value. Let's execute this producer and add some data. For the orders, we will use the order ID as the key and the product name and price as values. So we first provide the order ID as the key followed by the colon symbol and then provide a CSP string with the product name and value. Let's publish a second record with key as 1002, product as keyboard and value as 10. Kafka will now distribute these…

Contents