![JAR search and dependency download from the Maven repository](/logo.png)
kafka.entity.changelog.serde.CommandSerde Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kafka-entity-changelog Show documentation
Show all versions of kafka-entity-changelog Show documentation
Changelog service to create events from Kafka entity changes (e.g. topics, acls)
The newest version!
package kafka.entity.changelog.serde;
import com.google.protobuf.InvalidProtocolBufferException;
import kafka.entity.changelog.schema.Topic;
import org.apache.kafka.common.serialization.Deserializer;
import org.apache.kafka.common.serialization.Serde;
import org.apache.kafka.common.serialization.Serializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CommandSerde implements Serde {
static final Logger LOG = LoggerFactory.getLogger(CommandSerde.class);
@Override public Serializer serializer() {
return (topic, data) -> {
if (data != null) return data.toByteArray();
else return new byte[]{};
};
}
@Override public Deserializer deserializer() {
return (topic, data) -> {
try {
return Topic.Command.parseFrom(data);
} catch (InvalidProtocolBufferException e) {
LOG.error("Error deserializing topic event", e);
return null;
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy