Ben Aaron
08/10/2023, 11:46 PMwith open("/opt/flink/usrlib/LogRecord.avsc","r") as f:
avro_schema_string=f.read()
deserialization_schema = AvroRowDeserializationSchema(
avro_schema_string=avro_schema_string
)
kafka_consumer = FlinkKafkaConsumer(
topic="MyTopic",
deserialization_schema=deserialization_schema,
properties={
'bootstrap.servers': f'{host}:{port},
'group.id': my_consumer_group,
Flink is able to connect, but I'm getting errors like so:
Caused by: org.apache.avro.AvroRuntimeException: Malformed data. Length is negative: -1
at org.apache.avro.io.BinaryDecoder.readString(BinaryDecoder.java:308)
at org.apache.avro.io.ResolvingDecoder.readString(ResolvingDecoder.java:208)
at org.apache.avro.generic.GenericDatumReader.readString(GenericDatumReader.java:470)
I know the messages are valid, because they were serialized using the same schema and avro version before going into Kafka.
Does anyone have any suggestions? I'm new to the JVM, so I suspect that the fat jar I made to hold all my project dependencies isn't following best practices.sap1ens
08/11/2023, 2:12 AMM C (Mac)
08/11/2023, 2:36 PMM C (Mac)
08/11/2023, 2:39 PMBen Aaron
08/11/2023, 4:00 PMDo you use a Schema Registry when producing messages?@sap1ens, We do, but I'm not sure how to configure flink to consume from it.
sap1ens
08/11/2023, 4:12 PMRegistryAvroDeserializationSchema instead of AvroRowDeserializationSchema. This requires providing a Schema Registry client via SchemaCoderProvider, but I don’t have an example in Python for that.Ben Aaron
08/11/2023, 5:39 PMRegistryAvroDeserializationSchema at all?
I'm looking around in pyflink.datastream.formats.avro and I don't see any modules or classes that look like they reach out the JVM. I suppose I could implement my own to test.Ben Aaron
08/14/2023, 4:02 PMRegistryAvroDeserializationSchema is not currently implemented in PyFlink.Adrian Chang
08/15/2023, 2:32 AM