Hi, I'm new to Kafka, and I would like to use schema registry to manager
the schema of my topic.
The schema I've created:
curl -X POST -i -H "Content-Type: application/vnd.schemaregistry.v1+json"
--data '{ "schema": "{\"type\": \"record\",\"name\": \"Customer\",
\"fields\": [ { \"type\": \"int\", \"name\": \"id\" }, { \"type\":
\"string\", \"name\": \"name\" } ] }" }'
http://localhost:8081/subjects/Customer/versions
HTTP/1.1 200 OK
Date: Wed, 15 Feb 2017 07:03:49 GMT
Content-Type: application/vnd.schemaregistry.v1+json
Content-Length: 9
Server: Jetty(9.2.12.v20150709)
{"id":21}%
My Customer class:
public class Customer {
private int id;
private String name;
public Customer(int ID, String name) {
this.id = ID;
this.name = name;
}
//getters and setters
}
My main code is like the following:
for (int i = 0; i < total; i++) {
Customer customer = new Customer(i,"customer"+i);
producer.send(new ProducerRecord<String, Customer>("test1",
customer)).get();
}
I got the following error:
org.apache.kafka.common.errors.SerializationException: Error
serializing Avro message
Caused by: java.lang.IllegalArgumentException: Unsupported Avro type.
Supported types are null, Boolean, Integer, Long, Float, Double,
String, byte[] and IndexedRecord
at
io.confluent.kafka.serializers.AbstractKafkaAvroSerDe.getSchema(AbstractKafkaAvroSerDe.java:115)
I thought I followed the example of the book <Kafka:The Definitive Guide>