2016-11-21 3 views
0

Les schémas AVRO peuvent-ils être enregistrés auprès du service de registre de schéma confluent?Enregistrement d'un schéma AVRO avec un registre confluent

Comme par readme sur github https://github.com/confluentinc/schema-registry

Chaque exemple utilise un schéma JSON avec un seul champ et le type sans nom.

J'essaye de stocker le schéma suivant au dépôt mais avec différentes variantes obtenant l'erreur différente.

curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" --data '{"schema": "{"type": "record","name": "myrecord","fields": [{"name": "serialization","type": "string"},{"name": "compression","type": "string"},{"name": "encoding","type": "string"},{"name": "data","type": "string"}]}"}' 

Ou

curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" --data '{"schema": \"{\"type\": \"record\",\"name\": \"myrecord\",\"fields\": [{\"name\": \"data\",\"type\": \"string\"}]}\"}' http://localhost:8081/subjects/Kafka-key/versions 
+0

Oui. Absolument. Consultez cet exemple: https://github.com/confluentinc/examples/blob/3.1.x/kafka-streams/src/main/java/io/confluent/examples/streams/WikipediaFeedAvroLambdaExample.java –

+0

"avec différents variantes obtenant une erreur différente ": il serait utile si vous avez effectivement inclus ces erreurs dans votre question. –

Répondre

0

schéma Avro peut être enregistré à l'aide kafka en utilisant la commande ci-dessous

curl -X POST -i -H "Content-Type: application/vnd.schemaregistry.v1+json" --data '{"schema": "{\"type\": \"record\",\"name\": \"myrecord\",\"fields\": [{\"name\": \"serialization\",\"type\": \"string\"},{\"name\": \"compression\",\"type\": \"string\"},{\"name\": \"encoding\",\"type\": \"string\"},{\"name\": \"data\",\"type\": \"string\"}]}"}' http://localhost:8081/subjects/Kafka-key/versions 

Il vous manque quelques params.

Vous pouvez utiliser SchemaRegistryHelper pour obtenir un schéma permettant à n'importe quel ID de désérialiser des données.