|
4 | 4 | import com.fasterxml.jackson.databind.ObjectMapper; |
5 | 5 | import com.google.protobuf.Message; |
6 | 6 | import com.provectus.kafka.ui.cluster.model.KafkaCluster; |
| 7 | +import io.confluent.kafka.schemaregistry.SchemaProvider; |
7 | 8 | import io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider; |
8 | 9 | import io.confluent.kafka.schemaregistry.avro.AvroSchemaUtils; |
9 | 10 | import io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient; |
10 | 11 | import io.confluent.kafka.schemaregistry.client.SchemaRegistryClient; |
11 | 12 | import io.confluent.kafka.schemaregistry.client.rest.entities.Schema; |
12 | 13 | import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException; |
| 14 | +import io.confluent.kafka.schemaregistry.protobuf.ProtobufSchemaProvider; |
13 | 15 | import io.confluent.kafka.schemaregistry.protobuf.ProtobufSchemaUtils; |
14 | 16 | import io.confluent.kafka.serializers.KafkaAvroDeserializer; |
15 | 17 | import io.confluent.kafka.serializers.protobuf.KafkaProtobufDeserializer; |
@@ -41,14 +43,17 @@ public SchemaRegistryRecordDeserializer(KafkaCluster cluster, ObjectMapper objec |
41 | 43 | this.cluster = cluster; |
42 | 44 | this.objectMapper = objectMapper; |
43 | 45 |
|
44 | | - this.schemaRegistryClient = Optional.ofNullable(cluster.getSchemaRegistry()).map(e -> |
45 | | - new CachedSchemaRegistryClient( |
46 | | - Collections.singletonList(e), |
47 | | - CLIENT_IDENTITY_MAP_CAPACITY, |
48 | | - Collections.singletonList(new AvroSchemaProvider()), |
49 | | - Collections.emptyMap() |
50 | | - ) |
51 | | - ).orElse(null); |
| 46 | + this.schemaRegistryClient = Optional.ofNullable(cluster.getSchemaRegistry()) |
| 47 | + .map(schemaRegistryUrl -> { |
| 48 | + List<SchemaProvider> schemaProviders = List.of(new AvroSchemaProvider(), new ProtobufSchemaProvider()); |
| 49 | + return new CachedSchemaRegistryClient( |
| 50 | + Collections.singletonList(schemaRegistryUrl), |
| 51 | + CLIENT_IDENTITY_MAP_CAPACITY, |
| 52 | + schemaProviders, |
| 53 | + Collections.emptyMap() |
| 54 | + ); |
| 55 | + } |
| 56 | + ).orElse(null); |
52 | 57 |
|
53 | 58 | this.avroDeserializer = Optional.ofNullable(this.schemaRegistryClient) |
54 | 59 | .map(KafkaAvroDeserializer::new) |
|
0 commit comments