A Spring Kafka application demonstrating how to migrate from the @RetryableTopic annotation to a transactional retry mechanism.
The starting point is the RetryableTopicFooListener which is not using transactions. Tests for this class are implemented in RetryableTopicFooListenerIntegrationTest.
The transactional version is implemented in TransactionalFooListener and is activated by profile = "tx". Tests for this class are implemented in TransactionalFooListenerContainerTest.
TransactionalFooListenerContainerTest and TransactionalFooListenerSpringJUnitTest show the same transaction tests using ConfluentKafkaContainer and @SpringJUnitConfig respectively.
The ConcurrentKafkaListenerContainerFactory is configured with a DefaultAfterRollbackProcessor in
ListenerContainerFactoryConfig
An alternative approach using BeanPostProcessor is in
ListenerContainerFactoryBeanPostProcessor.
@SpringBoot- and @SpringJUnitConfig tests are sharing the same tests defined in ListenerTestBase
Java 21+ Docker (for running test container tests)
./gradlew clean check --info