You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Spring Cloud Stream Kinesis示例,如何在application.yml添加autoAddShards等属性?

Spring Cloud Stream Kinesis: Configuring autoAddShards and minShardCount

Hey there! Those two properties (autoAddShards and minShardCount) are specific to the Spring Cloud Stream Kinesis binder, and their placement depends on whether you want them to apply to your producer, consumer, or all Kinesis bindings globally. Let me break it down for you:

Option 1: Apply to the Producer (ordersOut)

If you want these settings to take effect for your message producer, nest them under producer.kinesis within the ordersOut binding:

spring:
  cloud:
    stream:
      bindings:
        ordersOut: 
          destination: test_stream
          content-type: application/json
          producer: 
            partitionKeyExpression: "1"
            kinesis:
              autoAddShards: true  # Enables automatic shard scaling for the producer
              minShardCount: 2     # Minimum number of shards the stream should maintain
        ordersIn:
          destination: test_stream
          content-type: application/json

Option 2: Apply to the Consumer (ordersIn)

For the message consumer, place the properties under consumer.kinesis in the ordersIn binding:

spring:
  cloud:
    stream:
      bindings:
        ordersOut: 
          destination: test_stream
          content-type: application/json
          producer: 
            partitionKeyExpression: "1"
        ordersIn:
          destination: test_stream
          content-type: application/json
          consumer:
            kinesis:
              autoAddShards: true  # Allows automatic shard addition for the consumer-side stream
              minShardCount: 2     # Ensures the stream never drops below this shard count

Option 3: Global Configuration (Applies to All Bindings)

If you want these settings to apply to all Kinesis bindings in your application, configure them at the global binder level:

spring:
  cloud:
    stream:
      kinesis:
        binder:
          autoAddShards: true
          minShardCount: 2
      bindings:
        ordersOut: 
          destination: test_stream
          content-type: application/json
          producer: 
            partitionKeyExpression: "1"
        ordersIn:
          destination: test_stream
          content-type: application/json

Quick Notes on the Properties:

  • autoAddShards: When enabled, the binder will automatically add shards to the Kinesis stream if the current throughput exceeds the stream's capacity (requires your Kinesis stream to allow automatic scaling).
  • minShardCount: Defines the minimum number of shards the stream should have; if the stream's current shard count drops below this value, the binder will scale it up to meet this threshold.

内容的提问来源于stack exchange,提问作者CHAYAN CHAKRABORTY

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:16:07