KTable 无法从实体化视图中获取数据

KTable unable fetch data from Materialized view

我在 Spring Boot 中使用 Kafka Streams。在我的用例中,当我收到客户事件时,我需要将其存储在 customer-store 实体化视图中,当我收到订单事件时,我需要加入客户并订购,然后将结果存储在 customer-order 实体化视图中。

StoreBuilder customerStateStore = Stores.keyValueStoreBuilder(Stores.persistentKeyValueStore("customer-store"),Serdes.String(), customerSerde)
                .withLoggingEnabled(new HashMap<>());
streamsBuilder.stream("customer", Consumed.with(Serdes.String(), customerSerde)).to("customer-to-ktable-topic",Produced.with(Serdes.String(), customerSerde));
KTable<String, Customer> customerKTable = streamsBuilder.table("customer-to-ktable-topic", Consumed.with(Serdes.String(), customerSerde),Materialized.as(customerStateStore.name()));

这是问题所在,当我收到 Order 事件并且我的 customerKTable returns null 和 join 操作变得无用。这不是它应该如何工作的。我的代码类似Kafka Music example, I created TestConsumer class to test this. Code uploaded to Github,供参考

此问题由 KTable 创建。我使用的 KTable 语法在语法上是正确的,但不起作用。参考 了解更多 信息。更改 KTable 语法对我有用。现在,customerKTable returns 事件或对象从物化视图中订购事件到达。