KafkaConsumerSyncWithOffsetRepoCommitIT.java

Overview

`KafkaConsumerSyncWithOffsetRepoCommitIT.java` is an integration test class designed to validate the behavior of the Apache Camel Kafka component when manual synchronous commits are used in conjunction with an offset repository. Specifically, it ensures that Kafka consumer offsets are correctly committed and stored using a state repository (`MemoryStateRepository`). This test verifies that the offset repository is properly updated when Kafka manual commit operations are performed synchronously.

The class extends a base test support class `BaseManualCommitTestSupport` and configures two Kafka consumer routes that consume messages from a Kafka topic with manual offset commit enabled but auto-commit disabled. The test verifies that manual commits are acknowledged and that the offset state is persisted in the repository.


Class: KafkaConsumerSyncWithOffsetRepoCommitIT

Description

Integration test class for testing Kafka consumer manual commits with synchronous commit manager and offset repository.

Inheritance

Package

Fields

Field Name

Type

Description

`TOPIC`

`String` (static final)

Kafka topic name used in the test.

`stateRepository`

`MemoryStateRepository` (static final)

In-memory offset repository instance, bound to Camel registry with name "stateRepository".

Annotations


Methods

after()

@AfterEach
public void after()

createRouteBuilder()

@Override
protected RouteBuilder createRouteBuilder()
RouteBuilder routeBuilder = kafkaConsumerSyncWithOffsetRepoCommitIT.createRouteBuilder();
context.addRoutes(routeBuilder);

kafkaManualCommitWithOffsetRepo()

@DisplayName("Tests that the offset repository gets updated when using in conjunction with the Sync commit manager")
@Test
public void kafkaManualCommitWithOffsetRepo() throws Exception

Important Implementation Details and Algorithms


Interactions with Other Parts of the System


Usage Scenario

This test file is used during the build process or manually by developers to verify that manual offset commits in Kafka consumers using Apache Camel are correctly persisted to an offset repository when using synchronous commit logic. This ensures reliability of message processing and offset tracking in environments where offset management is externalized.


Visual Diagram

classDiagram
    class KafkaConsumerSyncWithOffsetRepoCommitIT {
        +static final String TOPIC
        +static final MemoryStateRepository stateRepository
        +void after()
        +RouteBuilder createRouteBuilder()
        +void kafkaManualCommitWithOffsetRepo()
    }

    class RouteBuilder {
        +void configure()
    }

    class KafkaManualCommit {
        +void commit()
    }

    KafkaConsumerSyncWithOffsetRepoCommitIT --> RouteBuilder : createRouteBuilder() returns
    RouteBuilder --> KafkaManualCommit : uses in processor
    KafkaConsumerSyncWithOffsetRepoCommitIT --> MemoryStateRepository : stateRepository bean

Summary

This documentation provides all necessary details for developers and testers to understand the purpose, implementation, and usage of `KafkaConsumerSyncWithOffsetRepoCommitIT.java`.