Skip to content

A Spring Kafka application demonstrating how to migrate from the @RetryableTopic annotation to a transactional retry mechanism.

Notifications You must be signed in to change notification settings

roar-skinderviken/spring-kafka-retryable-transactional

Repository files navigation

spring-kafka-retryable-transactional

A Spring Kafka application demonstrating how to migrate from the @RetryableTopic annotation to a transactional retry mechanism.

Overview

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

Prerequisites

Java 21+ Docker (for running test container tests)

Running Test

./gradlew clean check --info

About

A Spring Kafka application demonstrating how to migrate from the @RetryableTopic annotation to a transactional retry mechanism.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages