TopicInfo.java

Overview

`TopicInfo.java` is a utility class within the Apache Camel Kafka component that encapsulates information about Kafka topics used for consumer subscriptions. It manages both static topic names and dynamic topic subscriptions based on regular expression patterns. The class provides a simple abstraction to represent either a fixed list of topic names or a pattern that matches multiple topics dynamically.

This file is essential in managing Kafka consumer subscription semantics, particularly when subscribing to topics by name or by pattern. It is part of the subscription support infrastructure in the Kafka consumer integration of Apache Camel.


Class: TopicInfo

Description

`TopicInfo` acts as a carrier for topic subscription information. It can represent:

This dual representation supports Kafka's native consumer subscription modes: either subscribing to specific topics or subscribing via a regex pattern.

Package

org.apache.camel.component.kafka.consumer.support.subcription

Fields

Field Name

Type

Description

`pattern`

`Pattern`

A regex pattern for dynamic subscription. Null if using explicit topic names.

`topicName`

`List`

A list of topic names parsed from a comma-separated string.


Constructors

TopicInfo(Pattern pattern, String topicName)

Creates a new `TopicInfo` instance.


Methods

boolean isPattern()


Pattern getPattern()


Collection<String> getTopics()


Implementation Details


Interaction with Other System Components


Usage Summary


Class Diagram

classDiagram
    class TopicInfo {
        -Pattern pattern
        -List<String> topicName
        +TopicInfo(Pattern pattern, String topicName)
        +boolean isPattern()
        +Pattern getPattern()
        +Collection<String> getTopics()
    }

Summary

`TopicInfo.java` provides a minimal but essential abstraction in the Apache Camel Kafka component to represent either a static list of Kafka topics or a dynamic subscription via regex patterns. It supports Kafka's flexible subscription model and promotes clean separation of concerns in the consumer subscription handling code. The class's immutability and simple API make it a reliable building block for managing topic subscriptions within the Kafka consumer integration layer.