Git Product home page Git Product logo

kafka-avro-confluent's Introduction

kafka-avro-confluent CircleCI

Kafka De/Serializer using avro and Confluent's Schema Registry

Migrating from 1.1.1-4 -> 1.1.1-5+

1.1.1-5 adds support for logical types. This support is automatic and will be used both in serialisation and deserialisation. If you need to deserialise to the underlying primitive types you will need to disable logical type conversion at the point of creating your deserialiser i.e.

(des/->avro-deserializer schema-registry :convert-logical-types? false)

Usage

Clojars Project

[ovotech/kafka-avro-confluent "2.1.0-7"]
(ns kafka-avro-confluent.readme-test
  (:require [kafka-avro-confluent.v2.deserializer :as des]
            [kafka-avro-confluent.v2.serializer :as ser]))

;; initialise the Confluent Schema Registry client:
(def config
  {;; NOTE auth optional!
   ;; :schema-registry/username "mr.anderson"
   ;; :schema-registry/password "42"
   :schema-registry/base-url "http://localhost:8081"})

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; # Deserializer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; implements org.apache.kafka.common.serialization.Deserializer

(des/->avro-deserializer config)

;; Without using logical types
(binding [abracad.avro.conversion/*use-logical-types* false]
  (des/->avro-deserializer schema-registry))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; # Serializer
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; implements org.apache.kafka.common.serialization.Serializer

;; meant to be used as a value-serializer in a KafkaProducer
(ser/->avro-serializer config schema)

;; If you want to use it as a key-serializer:
(ser/->avro-serializer config :key schema)

;; Using with a KafkaProducer:
;; e.g. (org.apache.kafka.clients.producer.KafkaProducer. key-serializer
;;                                                        value-serializer)

;; If the serializer will be used with multiple topics (each with its own schema):
(ser/->avro-serializer config (ser/->schemas-definition {topic1 schema1
                                                         topic2 schema2}))

Versions

The versions use this format:

${kafka_version}-${build_number}

For example:

0.10.0-4 # Kafka v = 0.10.0, kafka-avro-confluent build = 4
1.0.1-1  # Kafka v = 1.0.1 , kafka-avro-confluent build = 1

License

Copyright © 2017 OVO Energy Ltd.

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

kafka-avro-confluent's People

Contributors

bigsy avatar gavinesbergerovo avatar k2n avatar kelveden avatar markus-wa avatar oli-d-ovo avatar olib963 avatar vise890 avatar vise890-ovo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kafka-avro-confluent's Issues

any plan for implement org.apache.kafka.common.serialization.Serde

thank you for your project,
this really help me in kafka producer and consumer. but I also want to use this with kafka stream which is implement org.apache.kafka.common.serialization.Serde.
so, Do you have any plan to support that ? or I can help you write that part, I just need some help for starting point.

Unable to send Kafka message with Avro

Hi

First of all thanks so much for this library, it will make interacting with the Confluent stack so much simpler for us. I am having trouble getting a simple example of this working with clj-kafka however. Here is an example of a sample producer code:

(defn send-msg []
  (let [schema (:schema (reg/get-latest-schema-by-subject schema-registry "Person"))]
    (with-open [p (p/producer {"bootstrap.servers" "kafka1:9092"} (ser/->avro-serializer schema-registry schema) (ser/->avro-serializer schema-registry schema))]
     (p/send p (p/record "avro-test" ["Conor"])))))

This seems to make the call to get the schema correctly, but then once it tries to send the message it looks like it makes another call in the "serialize" method to POST a new version of the schema. This call is returning a 422. I am just wondering if you would know why this is or have a way to increase the logging so I could determine the issue:

kafka-schema-registry_1 | [2017-10-27 18:59:23,600] INFO 172.21.0.1 - - [27/Oct/2017:18:59:23 +0000] "GET /subjects/Person/versions/latest HTTP/1.1" 200 185 3 (io.confluent.rest-utils.requests) kafka-schema-registry_1 | [2017-10-27 18:59:23,819] INFO 172.21.0.1 - - [27/Oct/2017:18:59:23 +0000] "POST /subjects/avro-test-value/versions HTTP/1.1" 422 71 6 (io.confluent.rest-utils.requests)

`(send-msg)
2017-10-27 14:59:23 INFO ProducerConfig:113 - ProducerConfig values:
compression.type = none
metric.reporters = []
metadata.max.age.ms = 300000
metadata.fetch.timeout.ms = 60000
acks = 1
batch.size = 16384
reconnect.backoff.ms = 10
bootstrap.servers = [kafka1:9092]
receive.buffer.bytes = 32768
retry.backoff.ms = 100
buffer.memory = 33554432
timeout.ms = 30000
key.serializer = class kafka_avro_confluent.serializers.AvroSerializer
retries = 0
max.request.size = 1048576
block.on.buffer.full = true
value.serializer = class kafka_avro_confluent.serializers.AvroSerializer
metrics.sample.window.ms = 30000
send.buffer.bytes = 131072
max.in.flight.requests.per.connection = 5
metrics.num.samples = 2
linger.ms = 0
client.id =

2017-10-27 14:59:23 WARN ProducerConfig:121 - The configuration value.serializer = class kafka_avro_confluent.serializers.AvroSerializer was supplied but isn't a known config.
2017-10-27 14:59:23 WARN ProducerConfig:121 - The configuration key.serializer = class kafka_avro_confluent.serializers.AvroSerializer was supplied but isn't a known config.
ExceptionInfo clj-http: status 422 slingshot.support/stack-trace (support.clj:201)
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.