question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

startOffset not honored by KStream/KTable creation

See original GitHub issue

With 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:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
amleung21commented, Oct 17, 2018

@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 to earliest.

1reaction
amleung21commented, Oct 17, 2018

@sobychacko My mistake, that was a typo. spring.cloud.stream.kafka.streams.binder.configuration.auto.offset.reset was indeed used for the global setting.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found