Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabling protobuf in KafkaEsque, the schema registry is able to use p…
…rotobuf, protobuf messages can be displayed
- Loading branch information
Showing
14 changed files
with
135 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,6 @@ public enum MessageType { | |
BYTEARRAY, | ||
BYTEBUFFER, | ||
BYTES, | ||
UUID | ||
UUID, | ||
PROTOBUF_SR | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/at/esque/kafka/serialization/ForgivingProtobufAvroDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package at.esque.kafka.serialization; | ||
|
||
import com.google.protobuf.Message; | ||
import io.confluent.kafka.serializers.protobuf.KafkaProtobufDeserializer; | ||
import org.apache.kafka.common.serialization.Deserializer; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.Map; | ||
|
||
public class ForgivingProtobufAvroDeserializer implements Deserializer<Object> { | ||
|
||
private KafkaProtobufDeserializer<Message> baseDeserializer = new KafkaProtobufDeserializer<>(); | ||
private static final Logger logger = LoggerFactory.getLogger(ForgivingProtobufAvroDeserializer.class); | ||
|
||
public Object deserialize(byte[] bytes) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public Object deserialize(String s, byte[] bytes) { | ||
try { | ||
return baseDeserializer.deserialize(s, bytes); | ||
} catch (Exception e) { | ||
logger.warn("Failed Protobuf deserialization in topic {}", s); | ||
} | ||
return "Failed Protobuf deserialization! Content as String: " + new String(bytes); | ||
} | ||
|
||
@Override | ||
public void configure(Map<String, ?> configs, boolean isKey) { | ||
baseDeserializer.configure(configs, isKey); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.