|
25 | 25 | import java.util.Map; |
26 | 26 |
|
27 | 27 | import org.apache.kafka.common.serialization.Serdes; |
| 28 | +import org.apache.kafka.common.utils.Bytes; |
28 | 29 | import org.apache.kafka.streams.StreamsBuilder; |
29 | 30 | import org.apache.kafka.streams.StreamsConfig; |
30 | 31 | import org.apache.kafka.streams.kstream.KStream; |
31 | 32 | import org.apache.kafka.streams.kstream.KTable; |
32 | 33 | import org.apache.kafka.streams.kstream.Materialized; |
| 34 | +import org.apache.kafka.streams.state.BuiltInDslStoreSuppliers; |
| 35 | +import org.apache.kafka.streams.state.KeyValueStore; |
33 | 36 | import org.junit.jupiter.api.BeforeAll; |
34 | 37 | import org.junit.jupiter.api.Test; |
35 | 38 |
|
|
45 | 48 |
|
46 | 49 | /** |
47 | 50 | * @author Cédric Schaller |
| 51 | + * @author Soby Chacko |
48 | 52 | */ |
49 | 53 | @SpringJUnitConfig |
50 | 54 | @DirtiesContext |
@@ -80,18 +84,16 @@ public KafkaStreamsConfiguration kStreamsConfigWithInMemoryStateStores() { |
80 | 84 | props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.StringSerde.class); |
81 | 85 | props.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.StringSerde.class); |
82 | 86 | props.put(StreamsConfig.STATE_DIR_CONFIG, stateStoreDir.toString()); |
83 | | - |
84 | | - // Property introduced with KIP-591 (Kafka 3.2) and deprecated (but still supported) with Kafka 3.7 |
85 | | - props.put(StreamsConfig.DEFAULT_DSL_STORE_CONFIG, "in_memory"); |
86 | 87 | return new KafkaStreamsConfiguration(props); |
87 | 88 | } |
88 | 89 |
|
89 | 90 | @Bean |
90 | 91 | public KTable<?, ?> table(StreamsBuilder builder) { |
91 | 92 | KStream<Object, Object> stream = builder.stream("source-topic"); |
92 | | - return stream.groupByKey() |
93 | | - .count(Materialized.as("store")); |
94 | | - |
| 93 | + return stream |
| 94 | + .groupByKey() |
| 95 | + .count(Materialized.<Object, Long, KeyValueStore<Bytes, byte[]>>as("store") |
| 96 | + .withStoreType(BuiltInDslStoreSuppliers.IN_MEMORY)); |
95 | 97 | } |
96 | 98 | } |
97 | 99 | } |
0 commit comments