0

How to set acks = 1, max.in.flight.requests.per.connection = 10 properties for a Kafka publisher at channel level in spring cloud stream Kafka config.

I have tried the below ways to set both properties but it isn't working.

spring.cloud.stream.bindings.<channel-name>.producer.configuration.max.in.flight.requests.per.connection
spring.cloud.stream.kafka.bindings.<channel-name>.producer.configuration.max.in.flight.requests.per.connection

In the log of o.a.k.clients.producer.ProducerConfig I see acks = -1 and requests per connection = 1, where are set under spring.cloud.stream.kafka.binder.producer-properties

spring:
  cloud:
    stream:
      bindings:
        channel_out:
          destination: topicname
          binder: kafka
      kafka:
        binder:
          producer-properties:
            acks: all
            max.in.flight.requests.per.connection: 1
            retries: 10
        bindings:
          channel_out:
            producer:
              configuration:
                acks: 1
                max.in.flight.requests.per.connection: 50
Mike Reddington
  • 192
  • 2
  • 15
  • The second one should work, show the actual code and configuration. – Gary Russell Mar 14 '23 at 12:26
  • @GaryRussell Can we set the same property at spring.cloud.stream.kafka.binder.producer-properties namespace and spring.cloud.stream.kafka.bindings..producer.configuration namespace? For channels where it is set specifically it should pick that and for others it should pick properties under binder.producer-properties. – Mike Reddington Mar 16 '23 at 06:13
  • Correct; they are hierarchical; first it uses Boot `spring.kafka` properties; then binder properties; then binding properties in that order, to assemble the final properties map. – Gary Russell Mar 16 '23 at 12:10

0 Answers0