danielwegener / logback-kafka-appender

Logback appender for Apache Kafka
Apache License 2.0
644 stars 262 forks source link

Modify KeyingStrategy to create key as String/Object instead of only byte array #79

Closed moinsam closed 5 years ago

danielwegener commented 5 years ago

Hi @moinsam ! Thank you alot for this suggestion. I am thinking about going one step further and let the KeyingStrategy suggest a org.apache.kafka.common.serialization.Serializer class/className to configure the producer with as key serializer (which would still be overwritable via configuration). Otherwise one would always need to configure a matching KeyingStrategy with a matching Serializer. But most KeyingStrategies would already know which Serializer would work well. E.g. most KeyingStrategies creating a string could use the org.apache.kafka.common.serialization.StringSerializer.

From what I see, your example from the Readme would fail at runtime with class cast exceptions because our KafkaAppender would use a ByteArraySerializer if not configured otherwise (correct me if I am wrong).

moinsam commented 5 years ago

Hi @danielwegener ! You are right. I would be nice if we can overwrite the serializer via configuration. Sorry for the buggy PR. Thank you!