A Kafka SerDe to deserialize messages of an unknown serialization format
You can add kafka-brute-force-serde via Maven Central.
implementation group: 'com.bakdata.kafka', name: 'brute-force-serde', version: '1.0.0'
<dependency>
<groupId>com.bakdata.kafka</groupId>
<artifactId>brute-force-serde</artifactId>
<version>1.0.0</version>
</dependency>
For other build tools or versions, refer to the latest version in MvnRepository.
Make sure to also add Confluent Maven Repository to your build file.
You can use it from your Kafka Streams application like any other Serde
final Serde<Object> serde = new BruteForceSerde<>();
serde.configure(Map.of(), false);
By default, the Serde attempts to deserialize messages using the following Serdes in this order:
- SpecificAvroSerde
- GenericAvroSerde
- StringSerde
- ByteArraySerde
For each serialization format, BruteForceSerde first attempts deserialization using Kafka Large Message Serde and then uses the standard format.
You can find a list of all brute force configurations below. All other configuration properties are also delegated to the nested Serdes used by BruteForceSerde.
This serde also comes with support for Kafka Connect. You can add kafka-brute-force-connect via Maven Central.
implementation group: 'com.bakdata.kafka', name: 'brute-force-connect', version: '1.0.0'
<dependency>
<groupId>com.bakdata.kafka</groupId>
<artifactId>brute-force-connect</artifactId>
<version>1.0.0</version>
</dependency>
For other build tools or versions, refer to the latest version in MvnRepository.
To use it with your Kafka Connect connectors, just configure your converter as com.bakdata.kafka.BruteForceConverter
.
By default, the converter attempts to deserialize messages using the following converters in this order:
- AvroConverter
- StringConverter
- ByteArrayConverter
For each serialization format, BruteForceSerde first attempts deserialization using Kafka Large Message Converter and then uses the standard format.
You can find a list of all brute force configurations below. All configuration properties are also delegated to the nested Converters used by BruteForceConverter.
For general guidance on how to configure Kafka Connect converters, please have a look at the official documentation.
brute.force.large.message.enabled
Flag for enabling support for large-message-serde.
- Type: boolean
- Default: true
- Importance: low
brute.force.ignore.no.match
If set, the deserialization won't fail and instead keep the data as a byte array. This is equivalent to including ByteArray conversion in the corresponding conversion list.
- Type: boolean
- Default: true
- Importance: low
brute.force.serdes
A comma separated list of SerDes that should be tried.
- Type: list
- Default:
io.confluent.kafka.streams.serdes.avro.SpecificAvroSerde,io.confluent.kafka.streams.serdes.avro.GenericAvroSerde,org.apache.kafka.common.serialization.Serdes$StringSerde,org.apache.kafka.common.serialization.Serdes$ByteArraySerde
- Importance: medium
brute.force.converters
A comma separated list of converters that should be tried.
- Type: list
- Default:
io.confluent.connect.avro.AvroConverter,org.apache.kafka.connect.storage.StringConverter,org.apache.kafka.connect.converters.ByteArrayConverter
- Importance: medium
If you want to contribute to this project, you can simply clone the repository and build it via Gradle. All dependencies should be included in the Gradle files, there are no external prerequisites.
> git clone [email protected]:bakdata/kafka-brute-force-serde.git
> cd kafka-brute-force-serde && ./gradlew build
Please note, that we have code styles for Java. They are basically the Google style guide, with some small modifications.
We are happy if you want to contribute to this project. If you find any bugs or have suggestions for improvements, please open an issue. We are also happy to accept your PRs. Just open an issue beforehand and let us know what you want to do and why.
This project is licensed under the MIT license. Have a look at the LICENSE for more details.