confluent-kafka-python icon indicating copy to clipboard operation
confluent-kafka-python copied to clipboard

Support for multiple schemas in one topic

Open golfpreben opened this issue 7 years ago • 6 comments

Description

Support for multiple schemas in one topic for JAVA avro serializer was added in pull request: https://github.com/confluentinc/schema-registry/pull/680 Any chance this could be supported from python too?

How to reproduce

In tried to add value.subject.name.strategy to the config of the avro producer

avroProducer = AvroProducer({
'bootstrap.servers': '127.0.0.1:9092',
'schema.registry.url': 'http://127.0.0.1:8081',
'value.subject.name.strategy': 'io.confluent.kafka.serializers.subject.TopicNameStrategy'
}, default_key_schema=key_schema, default_value_schema=value_schema)

and got the following errror:

cimpl.KafkaException: KafkaError{code=_INVALID_ARG,val=-186,str="No such configuration property: "value.subject.name.strategy""}

Checklist

Please provide the following information:

  • [ ] confluent-kafka-python and librdkafka version (confluent_kafka.version() and confluent_kafka.libversion()):
  • [ ] Apache Kafka broker version:
  • [ ] Client configuration: {...}
  • [ ] Operating system:
  • [ ] Provide client logs (with 'debug': '..' as necessary)
  • [ ] Provide broker log excerpts
  • [ ] Critical issue

golfpreben avatar Nov 02 '18 09:11 golfpreben

See #442 & #401

OneCricketeer avatar Dec 05 '18 00:12 OneCricketeer

Are there any news regarding this issue? Both referenced issues (#442, #401) are closed. The issue #401 references #502, where nothing happens since months. As written in #560 the issue #502 might be included in the next release but (when) will this happen? Maybe @mhowlett can provide information, since he's reviewing the pull-request #502. Thanks in advance!

cschaible avatar May 30 '19 17:05 cschaible

Is there any workaround we can use while waiting for the new release ? Many thanks

enima2684 avatar Jul 17 '20 14:07 enima2684

AvroProducer is being replaced by the new avro serdes which support naming strategies: https://github.com/confluentinc/confluent-kafka-python/blob/master/confluent_kafka/schema_registry/avro.py

we don't yet support this: https://www.confluent.io/blog/multiple-event-types-in-the-same-kafka-topic/

mhowlett avatar Jul 17 '20 14:07 mhowlett

Thanks for the quick reply and good to know this functionality is already implemented.

However, it is not yet clear for me where/how to enter this configuration parameter ?

For the moment, I create a Producer object as follows :

        producer = AvroProducer(
            {
              'bootstrap.servers': "myBootstrapServers",
              'schema.registry.url': "mySchemaRegistryUrl",
              'enable.idempotence': 'true'
            },
            default_key_schema=self.get_key_schema(),
            default_value_schema=self.get_value_schema()     
 )

Is it something to add in the producer config ?

enima2684 avatar Jul 17 '20 15:07 enima2684

did you find a solution ?

amineouba avatar Apr 26 '22 10:04 amineouba