startOffset not honored by KStream/KTable creation
See original GitHub issueWith auto.offset.reset
(globally) set to “latest” and startOffset
set to “earliest” for a specific KTable/KSteam:
spring.cloud.stream.kafka.streams.binder.auto.offset.reset: latest
spring.cloud.stream.kafka.streams.bindings.configInput:
consumer:
materializedAs: configState
keySerde: org.apache.kafka.common.serialization.Serdes$StringSerde
valueSerde: org.apache.kafka.common.serialization.Serdes$StringSerde
startOffset: earliest
when the table/stream is created, only the global setting (“latest”) seems to take effect. i.e. The very first time this application comes up, only the latest offsets are processed.
I was able to confirm that extendedConsumerProperties
is correctly populated with startOffset=“earliest” here. However, it does not seem to be propagated down to the table/stream creation.
If I change this to include a Consumed
object with a hard-coded “earliest”
then the KTable does behave as expected and consume from the earliest offset on the first start of the application.
private <K,V> KTable<K,V> materializedAs(StreamsBuilder streamsBuilder, String destination, String storeName, Serde<K> k, Serde<V> v) {
return streamsBuilder.table(bindingServiceProperties.getBindingDestination(destination),
Consumed.with(k, v).withOffsetResetPolicy(Topology.AutoOffsetReset.EARLIEST),
Materialized.<K, V, KeyValueStore<Bytes, byte[]>>as(storeName)
.withKeySerde(k)
.withValueSerde(v));
}
Is this expected?
Thanks, Alex
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
How to consume the latest records from the topic using Spring ...
Basically, the start offset property is honored only when you start the application for the first time.
Read more >Spring Cloud Stream Kafka Binder Reference Guide
This setting is independent of the auto.topic.create.enable setting of the broker and does not influence it. If the server is set to auto-create...
Read more >Release Notes - Kafka - Version 2.0.0
The upgrade notes discuss any critical information about incompatibilities and breaking changes, performance changes, and any other changes that might impact ...
Read more >Kafka Streams vs. Kafka Consumer | Baeldung
2.2. Kafka Streams API · Single Kafka Stream to consume and produce · Perform complex processing · Do not support batch processing ·...
Read more >Streams DSL - Confluent Documentation
KStream-KTable joins are always non-windowed joins. They allow you to perform table lookups against a KTable (changelog stream) upon receiving a new record...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sobychacko And yes, we wanted to set the global setting to
latest
for one topic (our “data” topic) and have another topic (our “configuration” topic) be overridden toearliest
.@sobychacko My mistake, that was a typo.
spring.cloud.stream.kafka.streams.binder.configuration.auto.offset.reset
was indeed used for the global setting.