我有一个简单的 Spring Integration 流,它绑定到处理器以进行输入和输出。
我已将 Kafka 活页夹配置为映射输入和输出主题。这完美无缺。
假设我想将 3 个 Kafka 主题绑定到输入,导致 3 个配置的消费者从三个单独的 kafka 主题中提取,然后由我的 SI 流处理。
是否可以将多个 Kafka 主题映射到我的处理器的输入?如果是这样,该配置的外观如何?
我有一个简单的 Spring Integration 流,它绑定到处理器以进行输入和输出。
我已将 Kafka 活页夹配置为映射输入和输出主题。这完美无缺。
假设我想将 3 个 Kafka 主题绑定到输入,导致 3 个配置的消费者从三个单独的 kafka 主题中提取,然后由我的 SI 流处理。
是否可以将多个 Kafka 主题映射到我的处理器的输入?如果是这样,该配置的外观如何?
如果destination
属性是逗号分隔的列表,将为每个目标创建一个侦听器容器并绑定到同一个侦听器。
您还可以将该multiplex
属性设置为 true,这样我们就只有一个容器可以监听多个主题。
spring.cloud.stream.bindings.foo.consumer.multiplex=true
.
/**
* When set to true, the underlying binder will natively multiplex destinations on the
* same input binding. For example, in the case of a comma separated multiple
* destinations, the core framework will skip binding them individually if this is set
* to true, but delegate that responsibility to the binder.
*
* By default this property is set to `false` and the binder will individually bind
* each destinations in case of a comma separated multi destination list. The
* individual binder implementations that need to support multiple input bindings
* natively (multiplex) can enable this property.
*/
private boolean multiplex;
您必须设置多路复用属性才能启用它。