Fix Kakfa Stream multiple input sample.

Add new recipe for multiple instances of pollable consumers.
This commit is contained in:
Soby Chacko
2021-10-01 14:08:46 -04:00
parent 0f579a8c95
commit becc034169
2 changed files with 26 additions and 1 deletions

View File

@@ -14,7 +14,6 @@
<name>kafka-streams-multiple-input-topics</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2020.0.3</spring-cloud.version>
</properties>
<dependencies>

View File

@@ -0,0 +1,26 @@
# Gotchas when running multiple pollable consumers
## Problem Statement
How can I run multiple instances of the pollable consumers and generate unique client.id for each instance?
## Solution
Assuming that I have the following definition:
```
spring.cloud.stream.pollable-source: foo
spring.cloud.stream.bindings.foo-in-0.group: my-group
```
When running the application, the Kafka consumer generates a client.id (something like `consumer-my-group-1`).
For each instance of the application that is running, this `client.id` will be the same, causing unexpected issues.
In order to fix this, you can add the following property on each instance of the application:
```
spring.cloud.stream.kafka.bindings.foo-in-0.consumer.configuration.client.id=${client.id}
```
See this issue for more details: https://github.com/spring-cloud/spring-cloud-stream-binder-kafka/issues/1139