spring-cloud-stream icon indicating copy to clipboard operation
spring-cloud-stream copied to clipboard

Feature Request: Add maxAge to the binder properties

Open Fonexn opened this issue 2 years ago • 0 comments

Hello,

Coming from here: https://stackoverflow.com/questions/77510784/how-work-maxage-in-spring-kafka-factory-producer/77517766#77517766

Now you need to manually set maxAge for each binder programmatically, example:

    @Bean
    KafkaTransactionManager customKafkaTransactionManager() {
        KafkaMessageChannelBinder kafka = (KafkaMessageChannelBinder)this.binderFactory.getBinder("kafka1", MessageChannel.class);
        DefaultKafkaProducerFactory<byte[], byte[]> producerFactory = (DefaultKafkaProducerFactory<byte[], byte[]>) kafka.getTransactionalProducerFactory();

        producerFactory.setMaxAge(Duration.ofSeconds(60));

        return new KafkaTransactionManager(producerFactory);
    }

It would be good to add the possibility of configuring this property in each binder from the application properties in yaml. For example spring.cloud.stream.kafka.binder.transaction.maxAge in ms

Thanks

Fonexn avatar Nov 21 '23 11:11 Fonexn