Reconfiguring the Kafka producer

After you update a schema stored in the Schema Registry, you must reconfigure the producer to use the new schema.

Now that the consumer is already aware of the new schema, you can reconfigure the producer to send messages using the new schema.

Your producer has been created in a way that the schema file argument is optional. If that file is not provided, the producer tries to retrieve the latest version of the schema from Schema Registry with the topic name as the schema key.

Because you already uploaded the new schema to the Schema Registry, you only need to restart the producer without the schema file argument. Perform the following steps to get the producer to use the new schema:

You must have reconfigured the consumer to use the new schema.
  1. If the producer application is still running, stop it.
  2. Start the producer with the following command using the new schema:
    java \
      -cp ./target/kafka-client-avro-1.0-SNAPSHOT.jar \
      com.cloudera.examples.MachineDataProducer \
      ./producer.properties
    The producer displays messages with the correct values assigned to the new os_type field, as shown in the following example:
    ... INFO  c.c.examples.MachineDataConsumer - Received message: (null, {..., "os_type": "mac", ...}) at partition ...