首页 > 解决方案 > KGroupedStream 与 cogroup、聚合和抑制

问题描述

试图联合、聚合和抑制流,这会导致 -

Caused by: java.lang.ClassCastException: class org.apache.kafka.streams.kstream.internals.PassThrough cannot be cast to class org.apache.kafka.streams.kstream.internals.KTableProcessorSupplier (org.apache.kafka.streams.kstream.internals.PassThrough and org.apache.kafka.streams.kstream.internals.KTableProcessorSupplier are in unnamed module of loader 'app')
        val stream1 = requestStreams.merge(successStreams).merge(errorStreams)
                .groupByKey(Grouped.with(Serdes.String(), serdesConfig.notificationSerde()))

        val streams2 = confirmationStreams
                .groupByKey(Grouped.with(Serdes.String(), serdesConfig.confirmationsSerde()))

        val cogrouped = stream1.cogroup(notificationAggregator).cogroup(streams2, confirmationsAggregator)
                .windowedBy(TimeWindows.of(Duration.ofMinutes(notificationStreamsConfig.joinWindowMinutes.toLong())).grace(Duration.ofMinutes(notificationStreamsConfig.graceDurationMinutes.toLong())))
                .aggregate({ null }, Materialized.`as`<String, NotificationMetric, WindowStore<Bytes, ByteArray>>("time-windowed-aggregated-stream-store")
                        .withValueSerde(serdesConfig.notificationMetricSerde()))
                 .suppress(Suppressed.untilWindowCloses(unbounded()))
                .toStream()

但是,如果我删除它,.suppress它工作正常。

标签: apache-kafkaapache-kafka-streams

解决方案


推荐阅读