Skip to content

Instantly share code, notes, and snippets.

@vikas-tikoo-zefr
Created November 14, 2018 21:12
Show Gist options
  • Save vikas-tikoo-zefr/c68edf760c319105e175394b32f4a01e to your computer and use it in GitHub Desktop.
Save vikas-tikoo-zefr/c68edf760c319105e175394b32f4a01e to your computer and use it in GitHub Desktop.
import org.apache.kafka.common.serialization.Deserializer
import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient
import io.confluent.kafka.serializers.KafkaAvroDeserializer
class StringAvroDeserializer : Deserializer<String> {
private val inner: KafkaAvroDeserializer
constructor() {
inner = KafkaAvroDeserializer()
}
/**
* For testing purposes only.
*/
internal constructor(client: SchemaRegistryClient) {
inner = KafkaAvroDeserializer(client)
}
override fun configure(deserializerConfig: Map<String, *>,
isDeserializerForRecordKeys: Boolean) {
inner.configure(deserializerConfig, isDeserializerForRecordKeys)
}
override fun deserialize(topic: String, bytes: ByteArray): String {
return inner.deserialize(topic, bytes) as String
}
override fun close() {
inner.close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment