简体   繁体   中英

Disable kafka producer from properties configuration

How can a producer set up from a Kafka factory be disabled?

I started from this example from https://docs.spring.io/spring-kafka/reference/html/ 在此处输入图像描述

I expected that adding a property like

props.put("autoStartup", "false");

would disable the message sending, but it does not seem to work. Running the application still sends messages.

There's no producer property like autoStartup , so it doesn't mean disable the message sending . For the producer configuration, you could see here .

In Spring Kafka, autoStartup is used for Listener Container .

You could set this property by: In @KafkaListener

@KafkaListener(id = "myContainer", topics = "myTopic", autoStartup = "false")

Or

**ListenerContainerFactory.setAutoStartup(Boolean autoStartup)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM