ccloud kafka topic create --partitions 1 test-topic
ccloud kafka topic produce test-topic --value-format avro --schema /path/to/schema.json
{"myField":"test","myField2":1}
{"myField":"foo","myField2":2}
Finish Getting Started with Schema Registry Produce and consume messages with schemas using the Confluent Schema Registry
- Log in to your cluster using the ccloud login command with the cluster URL specified.
ccloud login
- Set the Confluent Cloud environment and cluster
ccloud environment use env-xxx
ccloud kafka cluster use lkc-xxx
- If you don't have a Kafka API key, generate one and set it to use (replacing <API_KEY> with generated key) from the CLI
ccloud api-key create --resource lkc-xxx
ccloud api-key use <API_KEY> --resource lkc-xxx
- Produce a message using your schema (replace <PATH_TO_SCHEMA_FILE> with your local path to the schema file)
ccloud kafka topic produce orders --value-format jsonschema --schema <PATH_TO_SCHEMA_FILE>
Enter the Schema Registry API key and secret created previously. Then, produce a message formatted accordingly to the schema created for the topic "orders".
{"orderId":2122453, "orderTime": 1607641868, "orderAddress":"899 W Evelyn Ave, Mountain View, CA 94041"}
- Consume the message you just produced by retrieving the schema from the Schema Registry (ctrl+C to stop the produce command from previous step or open a new terminal) ccloud kafka topic consume orders --value-format jsonschema --from-beginning
bootstrap.servers=pkc-xxx.europe-west1.gcp.confluent.cloud:9092
security.protocol=SASL_SSL
sasl.mechanisms=PLAIN
sasl.username=xxx
sasl.password=xxx