[ 
https://issues.apache.org/jira/browse/BEAM-7310?focusedWorklogId=374620&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-374620
 ]

ASF GitHub Bot logged work on BEAM-7310:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Jan/20 15:32
            Start Date: 20/Jan/20 15:32
    Worklog Time Spent: 10m 
      Work Description: iemejia commented on pull request #10563: [BEAM-7310] 
Add support of Confluent Schema Registry for KafkaIO
URL: https://github.com/apache/beam/pull/10563#discussion_r368600159
 
 

 ##########
 File path: 
sdks/java/io/kafka/src/test/java/org/apache/beam/sdk/io/kafka/KafkaIOTest.java
 ##########
 @@ -391,6 +451,84 @@ public static void addCountingAsserts(
     PAssert.thatSingleton(input.apply("Max", Max.globally())).isEqualTo(max);
   }
 
+  private static class MockSchemaRegistryClientFactoryFn
+      implements SerializableFunction<String, SchemaRegistryClient> {
+
+    private static final String SCHEMA_STRING =
+        "{\"namespace\": \"example.avro\",\n"
+            + " \"type\": \"record\",\n"
+            + " \"name\": \"AvroGeneratedUser\",\n"
+            + " \"fields\": [\n"
+            + "     {\"name\": \"name\", \"type\": \"string\"},\n"
+            + "     {\"name\": \"favorite_number\", \"type\": [\"int\", 
\"null\"]},\n"
+            + "     {\"name\": \"favorite_color\", \"type\": [\"string\", 
\"null\"]}\n"
+            + " ]\n"
+            + "}";
+
+    private static final Schema SCHEMA = new 
Schema.Parser().parse(SCHEMA_STRING);
+
+    private final String keySchemaSubject;
+    private final String valueSchemaSubject;
+
+    private MockSchemaRegistryClientFactoryFn(String keySubject, String 
valueSubject) {
+      this.keySchemaSubject = keySubject;
+      this.valueSchemaSubject = valueSubject;
+    }
+
+    @Override
+    public SchemaRegistryClient apply(String schemaRegistryURL) {
+      SchemaRegistryClient registryClient = new MockSchemaRegistryClient();
+      registerSchemaBySubject(registryClient, keySchemaSubject);
+      registerSchemaBySubject(registryClient, valueSchemaSubject);
+      return registryClient;
+    }
+
+    private void registerSchemaBySubject(
+        SchemaRegistryClient registryClient, String schemaSubject) {
+      try {
+        registryClient.register(schemaSubject, SCHEMA);
+      } catch (IOException | RestClientException e) {
+        throw new IllegalArgumentException(
+            "Unable to register schema for subject: " + schemaSubject, e);
+      }
+    }
+  }
+
+  @Test
+  public void testReadAvroKeyValuesWithSchemaRegistry() {
+    int numElements = 100;
+    String topic = "my_topic";
+    String keySubject = topic + "-key";
 
 Review comment:
   Rename to `keySchemaSubject` (same for `valueSchemaSubject`)
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 374620)
    Time Spent: 3h 10m  (was: 3h)

> Confluent Schema Registry support in KafkaIO
> --------------------------------------------
>
>                 Key: BEAM-7310
>                 URL: https://issues.apache.org/jira/browse/BEAM-7310
>             Project: Beam
>          Issue Type: Improvement
>          Components: io-java-kafka
>    Affects Versions: 2.12.0
>            Reporter: Yohei Shimomae
>            Assignee: Alexey Romanenko
>            Priority: Minor
>          Time Spent: 3h 10m
>  Remaining Estimate: 0h
>
> Confluent Schema Registry is useful when we manage Avro Schema but  KafkaIO 
> does not support Confluent Schema Registry as discussed here.
> https://stackoverflow.com/questions/56035121/unable-to-connect-from-dataflow-job-to-schema-registry-when-schema-registry-requ
> https://lists.apache.org/thread.html/7695fccddebd08733b80ae1e43b79b636b63cd5fe583a2bdeecda6c4@%3Cuser.beam.apache.org%3E



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to