boyuanzz commented on a change in pull request #13282:
URL: https://github.com/apache/beam/pull/13282#discussion_r520985187
##########
File path:
sdks/java/io/kafka/src/test/java/org/apache/beam/sdk/io/kafka/KafkaIOIT.java
##########
@@ -115,6 +122,43 @@ public static void setup() throws IOException {
.get();
}
+ @Test
+ public void testKafkaIOWithRunnerV2() throws IOException {
+ writePipeline
+ .apply("Generate records", Read.from(new
SyntheticBoundedSource(sourceOptions)))
+ .apply("Measure write time", ParDo.of(new TimeMonitor<>(NAMESPACE,
WRITE_TIME_METRIC_NAME)))
+ .apply("Write to Kafka", writeToKafka());
+
+ readPipeline.getOptions().as(Options.class).setStreaming(true);
+ PCollection<Integer> elementCount =
+ readPipeline
+ .apply("Read from Runner V2 Kafka", readFromKafka())
+ .apply(
+ "Measure read time", ParDo.of(new TimeMonitor<>(NAMESPACE,
READ_TIME_METRIC_NAME)))
+ .apply("Map records to strings", MapElements.via(new
MapKafkaRecordsToStrings()))
+ .apply(
+ "Keyed by empty key",
+ MapElements.into(new TypeDescriptor<KV<byte[], String>>() {})
+ .via(element -> KV.of(new byte[0], element)))
+ .apply(
+ "Counting elements", ParDo.of(new
CountingElementFn(options.getNumberOfRecords())));
Review comment:
Yes, counter works as well. I think we can use existing element counter
as well.
----------------------------------------------------------------
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:
[email protected]