AnkushKhanna / kafka-helper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using schema registry with MockedStreams Kafka

Using mocked streams with AVRO and schema registry in Kafka have been a problem.

Mocked streams works fine for StringSerdes, but using SpecificAvroSerde or Avro type did not work so well.

Test suit

I have created a WireMock schema-registry client in SchemaRegistryAvroTest

You can simply extend to any of your test using extend as show in PersonTopologyBuilderTest

For now there is no library available, you can use it via just copying the SchemaRegistryAvroTest code in your code base.

Usage

You have to specifiy your schema registry url as s"http://localhost:${httpMockPort()}" in your test and register your schema as follow:

  register(s"input-topic-key", PersonKey.SCHEMA$)
  register(s"input-topic-value", PersonRecord.SCHEMA$)

where input-topic is the name of your input topic.

Example

PersonTopologyBuilderTest

Avrohugger

Using avro hugger to generate case classes from avro schema. PersonKey and PersonRecord are case classes generated by Avrohugger.

Please leave a Star if you use this code - Thank you

About

License:MIT License


Languages

Language:Scala 100.0%