问题
I have the following properties for my Spring Cloud Stream application that uses Kafka Streams Binder:
spring.cloud.stream.bindings:
windowStream-in-0:
destination: input
windowStream-out-0:
destination: window1
hint1Stream-in-0:
destination: window1
hint1Stream-out-0:
destination: hints
realityStream-in-0:
destination: input
realityStream-in-1:
destination: window1
consumer:
timestampExtractorBeanName: anotherTimestampExtractor
realityStream-out-0:
destination: hints
countStream-in-0:
destination: hints
spring.cloud.stream.kafka.streams:
default:
consumer:
timestampExtractorBeanName: timestampExtractor
binder:
functions:
windowStream:
applicationId: mock-stream-window1
hint1Stream:
applicationId: mock-stream-hints
realityStream:
applicationId: mock-stream-reality
countStream:
applicationId: mock-stream-count
stateStoreRetry:
maxAttempts: 3
backOffInterval: 1000
configuration:
schema.registry.url: mock://mock-stream-registry
default.key.serde: org.apache.kafka.common.serialization.Serdes$StringSerde
default.value.serde: io.confluent.kafka.streams.serdes.avro.SpecificAvroSerde
commit.interval.ms: 100
What I am trying to do is to use the "timestampExtractor" for all streams except for one, called "realityStream".
For that I set the spring.cloud.stream.kafka.streams.default.consumer.timestampExtractorBeanName
to timestampExtractor
and then try to "override" it for the "realityStream" by setting spring.cloud.stream.bindings.realityStream-in-1.consumer.timestampExtractorBeanName
Unfortunately, it seems that my override doesn't work, since only "timestampExtractor" is getting called only, as I can see in the debugger (and in my test results).
Am I applying the configuration wrong, or have wrong expectation?
Here's a picture of the streams in my single Spring Cloud Streams application:
(orange circle is the place where I want to apply non-default timestamp extractor)
回答1:
The override is in the wrong place; it needs to be under the ....kafka.streams.bindings.realityStream-in-1....
property.
It's a kafka-specific property; you have it in the generic bindings properties (common to all binders).
来源:https://stackoverflow.com/questions/62039706/timestampextractorbeanname-setting-in-the-spring-cloud-stream-application-doesn