-
Notifications
You must be signed in to change notification settings - Fork 338
Encoding messages with Avro
Daniel Schierbeck edited this page Feb 10, 2016
·
2 revisions
It's possible to automatically register Avro schemas with a Schema Registry using AvroTurf.
require "avro_turf"
require "kafka"
# You need to pass the URL of your Schema Registry.
avro = AvroTurf::Messaging.new(registry_url: "http://my-registry:8081/")
# Encoding data has the side effect of registering the schema. This only
# happens the first time a schema is used.
data = avro.encode({ "title" => "hello, world" }, schema_name: "greeting")
# Assuming you've set up `producer`:
producer.produce(data, topic: "greetings")