embeddedkafka / embedded-kafka

A library that provides an in-memory Kafka instance to run your tests against.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deserializer custom types

SarpongAbasimi opened this issue · comments

Hey, If I have this type

sealed trait OperationType extends Product with Serializable
 final case object NewSubscription                   extends OperationType
  final case object DeleteSubscription                extends OperationType
  final case class Organization(organization: String) extends AnyVal

  final case class MessageEvent(
      operationType: OperationType,
      organization: Organization,
      repository: Repository
  )

I am trying to create a custom deserializer for the MessageEvent type just like we have for String.
Is there an Api for this please?

Ref - https://github.com/embeddedkafka/embedded-kafka/blob/master/embedded-kafka/src/test/scala/io/github/embeddedkafka/EmbeddedKafkaMethodsSpec.scala#L126

No reply so closing this issue but I still would love an answer

Hi @SarpongAbasimi, sorry for the late reply.
You can serialize case classes using Avro, Protobuf, or JSON, all of which are supported by Confluent Schema Registry.
You can find an example using JSON here.