Integrating a large XML file size with Kafka

Viewed 310

The XML file (~100 Mb) is a batch export by an external system of its entire database (The Batch export is every 6 hours). I can not change the integration to use Debezium connector for example. I have access only to the XML file.

What would be the best solution to consume the file with Apache Kafka? Or, an architecture to send single messages of the XML file with an XSD schema?

Is not receiving its content on a large single message size a bad thing for the architecture?

2 Answers

The default max.message.bytes configuration on broker and topic level in Kafka is set to c. 1MB and it is not advisable to significantly increase that configuration as Kafka is not optimizes to handle large messages.

Is see two options to solve this:

  • Before loading the XML into Kafka, split it into chunks that represent an individual row of the database. In addition, us a typesafe format (such as AVRO) in combination with a Schema Registry to tell potential consumers how to read the data.

  • Dependent on what needs to be done with the large XML file, you could also store the XML in a resilient location (such as HDFS) and only provide the location path in a Kafka message. That way, a consumer can consume the paths from the Kafka topic and make some processing on them.

Writing a Kafka producer that unamarshalls XML files to Java Objects, Sends serialized objects in Avro format to the cluster was the solution for me.

Related