我开发了基于SpringCloudStream3.0.3.RELEASE的kafka消费者应用程序。(SpringBoot 2.3.4 developed )
当我停止这个应用程序时,我希望使用者优雅地关闭。Similar Questions
停止轮询新messages
春云流默认为此工作吗?那有相关的文件吗?
关于您的信息,我使用的春天云流卡夫卡如下。
#Message handler
@Component
public class MessageHandler {
@Bean
public Consumer<MyEvent> handleMessage() {
return message -> {...}
}
...
}
#application.yml
spring:
cloud:
stream:
bindings:
handleMessage-in-0:
destination: myevent
group: test-group
consumer:
maxAttempts: 2
concurrency: 10
function:
definition: handleMessage
...发布于 2021-05-24 15:09:37
正如您所引用的答案中所提到的,您可以使用一个shutdownTimeout bean增加ListenerContainerCustomizer容器属性(默认为10秒)。
@Bean
public ListenerContainerCustomizer<AbstractMessageListenerContainer<?, ?>> customizer() {
return (container, dest, group) -> container.getContainerProperties()
.setShutdownTimeout(30_000L);
}https://stackoverflow.com/questions/67614658
复制相似问题