Skip to content

Add spring.kafka.listener.await-async-results-on-stop property #51561

Description

@nikita-kibitkin

spring-kafka is adding an opt-in container property awaitAsyncResultsOnStop (spring-projects/spring-kafka#4519, PR spring-projects/spring-kafka#4619, targeted at 4.2.0-M2 with backports to 4.0.x and 4.1.x, not merged yet): on container stop the in-flight async listener results (CompletableFuture, Mono, Kotlin suspend) are awaited within shutdownTimeout and then cancelled, so listener work no longer outlives the container and races downstream bean destruction during application shutdown. The upstream report came from production: suspend listeners writing to reactive MongoDB failed on every rolling deploy because the client was closed while they were still running.

spring.kafka.listener.* does not map the property, so enabling it takes a ContainerCustomizer bean or factory code. The reporter of the upstream issue asked for a Boot property to make adoption easier: spring-projects/spring-kafka#4619 (comment)

Proposal: spring.kafka.listener.await-async-results-on-stop on KafkaProperties.Listener, mapped in ConcurrentKafkaListenerContainerFactoryConfigurer#configureContainer next to the existing immediate-stop mapping, with the matching case in KafkaAutoConfigurationTests.

I'd like to do the PR for this myself once a spring-kafka release with the property is out.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: blockedAn issue that's blocked on an external project changetype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions