Search in sources :

Example 1 with KafkaProtobufDeserializer

use of io.confluent.kafka.serializers.protobuf.KafkaProtobufDeserializer in project ksql by confluentinc.

the class KsqlProtobufSerializerTest method setup.

@Before
public void setup() {
    final ImmutableMap<String, Object> configs = ImmutableMap.of(AbstractKafkaSchemaSerDeConfig.AUTO_REGISTER_SCHEMAS, true, AbstractKafkaSchemaSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG, "");
    deserializer = new KafkaProtobufDeserializer(schemaRegistryClient, configs);
}
Also used : KafkaProtobufDeserializer(io.confluent.kafka.serializers.protobuf.KafkaProtobufDeserializer) ByteString(com.google.protobuf.ByteString) Matchers.containsString(org.hamcrest.Matchers.containsString) Before(org.junit.Before)

Example 2 with KafkaProtobufDeserializer

use of io.confluent.kafka.serializers.protobuf.KafkaProtobufDeserializer in project ksql by confluentinc.

the class RecordFormatter method newProtobufDeserializer.

private static Deserializer<?> newProtobufDeserializer(final SchemaRegistryClient srClient) {
    final Printer printer = TextFormat.printer();
    final KafkaProtobufDeserializer<?> inner = new KafkaProtobufDeserializer<>(srClient);
    return (topic, data) -> {
        final Message msg = inner.deserialize(topic, data);
        if (msg == null) {
            return null;
        }
        return printer.shortDebugString(msg);
    };
}
Also used : Arrays(java.util.Arrays) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ImmutableList(com.google.common.collect.ImmutableList) StringDeserializer(org.apache.kafka.common.serialization.StringDeserializer) Windowed(org.apache.kafka.streams.kstream.Windowed) Objects.requireNonNull(java.util.Objects.requireNonNull) StreamSupport(java.util.stream.StreamSupport) KafkaJsonSchemaDeserializer(io.confluent.kafka.serializers.json.KafkaJsonSchemaDeserializer) ZoneOffset(java.time.ZoneOffset) Deserializer(org.apache.kafka.common.serialization.Deserializer) TextFormat(com.google.protobuf.TextFormat) TimeWindowedDeserializer(org.apache.kafka.streams.kstream.TimeWindowedDeserializer) KafkaProtobufDeserializer(io.confluent.kafka.serializers.protobuf.KafkaProtobufDeserializer) Iterator(java.util.Iterator) SessionWindowedDeserializer(org.apache.kafka.streams.kstream.SessionWindowedDeserializer) UTF_8(java.nio.charset.StandardCharsets.UTF_8) KsqlJsonDeserializer(io.confluent.ksql.serde.json.KsqlJsonDeserializer) Printer(com.google.protobuf.TextFormat.Printer) LongDeserializer(org.apache.kafka.common.serialization.LongDeserializer) IOException(java.io.IOException) Streams(com.google.common.collect.Streams) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) DoubleDeserializer(org.apache.kafka.common.serialization.DoubleDeserializer) KafkaAvroDeserializer(io.confluent.kafka.serializers.KafkaAvroDeserializer) Bytes(org.apache.kafka.common.utils.Bytes) List(java.util.List) Stream(java.util.stream.Stream) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) DateTimeFormatter(java.time.format.DateTimeFormatter) Message(com.google.protobuf.Message) BytesDeserializer(org.apache.kafka.common.serialization.BytesDeserializer) Optional(java.util.Optional) IntegerDeserializer(org.apache.kafka.common.serialization.IntegerDeserializer) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Message(com.google.protobuf.Message) KafkaProtobufDeserializer(io.confluent.kafka.serializers.protobuf.KafkaProtobufDeserializer) Printer(com.google.protobuf.TextFormat.Printer)

Aggregations

KafkaProtobufDeserializer (io.confluent.kafka.serializers.protobuf.KafkaProtobufDeserializer)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 Streams (com.google.common.collect.Streams)1 ByteString (com.google.protobuf.ByteString)1 Message (com.google.protobuf.Message)1 TextFormat (com.google.protobuf.TextFormat)1 Printer (com.google.protobuf.TextFormat.Printer)1 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)1 KafkaAvroDeserializer (io.confluent.kafka.serializers.KafkaAvroDeserializer)1 KafkaJsonSchemaDeserializer (io.confluent.kafka.serializers.json.KafkaJsonSchemaDeserializer)1 KsqlJsonDeserializer (io.confluent.ksql.serde.json.KsqlJsonDeserializer)1 IOException (java.io.IOException)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 Instant (java.time.Instant)1 ZoneOffset (java.time.ZoneOffset)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 Arrays (java.util.Arrays)1 Iterator (java.util.Iterator)1 List (java.util.List)1