The KafkaEssentials class provides essential methods and properties for interacting with a Kafka messaging system. This class is designed to be used statically and should not be instantiated.

The class includes a static instance of the Kafka client and configuration settings required to connect to a Kafka cluster.

await KafkaEssentials.connectToKafka();

If the class is instantiated directly.

Constructors

Properties

Methods

Constructors

Properties

kafka: Kafka

A static instance of the Kafka class. This instance is used to interact with the Kafka messaging system.

kafkaConfig: KafkaConfig

Configuration settings for Kafka.

This static property holds the configuration settings required to connect and interact with a Kafka cluster.

Methods

  • Connects to a Kafka instance using the provided configuration.

    This method initializes a Kafka client with the specified client ID, brokers, and log level. It also sets up custom logging for different log levels (ERROR, WARN, INFO, DEBUG).

    Returns Promise<void>

    If Kafka is already connected or if the brokers configuration is missing.

    If there is an error during the connection attempt.

    await KafkaEssentials.connectToKafka();