SubscribeAdapter.java

Overview

`SubscribeAdapter.java` defines a single interface, `SubscribeAdapter`, which serves as a pluggable adapter for handling custom subscriptions in the context of Apache Kafka consumers within the Apache Camel Kafka component. This interface abstracts the mechanism of subscribing a Kafka consumer to topics, allowing different subscription strategies to be implemented and plugged in as needed.

The interface is designed to work with Kafka's native `Consumer` and `ConsumerRebalanceListener` APIs, and it integrates with Camel's internal representation of topic information (`TopicInfo`). By providing this adapter, the system promotes flexibility and extensibility in how Kafka topic subscriptions are managed.


Detailed Description

Interface: SubscribeAdapter

public interface SubscribeAdapter {
    void subscribe(Consumer<?, ?> consumer, ConsumerRebalanceListener reBalanceListener, TopicInfo topicInfo);
}

Purpose

`SubscribeAdapter` defines a contract for subscribing a Kafka consumer to topics with support for rebalance listeners and topic metadata encapsulated by Camel.

Method

subscribe
void subscribe(Consumer<?, ?> consumer, ConsumerRebalanceListener reBalanceListener, TopicInfo topicInfo);

Important Implementation Details


Interaction with Other Parts of the System


Mermaid Class Diagram

classDiagram
    class SubscribeAdapter {
        <<interface>>
        +subscribe(consumer: Consumer<?, ?>, reBalanceListener: ConsumerRebalanceListener, topicInfo: TopicInfo) void
    }

    class Consumer {
        <<from Kafka API>>
    }
    
    class ConsumerRebalanceListener {
        <<from Kafka API>>
    }

    class TopicInfo {
        <<Camel Kafka topic metadata>>
    }

    SubscribeAdapter ..> Consumer : uses
    SubscribeAdapter ..> ConsumerRebalanceListener : uses
    SubscribeAdapter ..> TopicInfo : uses

Summary

This interface is essential for developers extending or customizing how Kafka consumers are subscribed to topics in the Camel integration framework.