Class: Kafka

KafkaJS.Kafka(config)

This class holds common configuration for clients, and an instance can be used to create producers, consumers, or admin clients.

Constructor

new Kafka(config)

The configuration provided will be shared across all clients created using this Kafka object.

Properties listed within CONFIGURATION.md can be used as keys for this object.

A number of KafkaJS-compatible configuration options can be provided as an object with the kafkaJS key as illustrated in MIGRATION.md.

Parameters:
Name Type Description
config object

The common configuration for all clients created using this Kafka object.

Methods

admin(config) → {KafkaJS.Admin}

Creates a new admin client.

An object containing the configuration for the admin client to be created. This will be merged with the common configuration provided when creating the RdKafka.Kafka object, and the same set of keys can be used.

Parameters:
Name Type Description
config object

The configuration for the admin client to be created.

Returns:
Type
KafkaJS.Admin

consumer(config) → {KafkaJS.Consumer}

Creates a new consumer.

An object containing the configuration for the consumer to be created. This will be merged with the common configuration provided when creating the RdKafka.Kafka object, and the same set of keys can be used.

Parameters:
Name Type Description
config object

The configuration for the consumer to be created.

Returns:
Type
KafkaJS.Consumer

producer(config) → {KafkaJS.Producer}

Creates a new producer.

An object containing the configuration for the producer to be created. This will be merged with the common configuration provided when creating the RdKafka.Kafka object, and the same set of keys can be used.

Parameters:
Name Type Description
config object

The configuration for the producer to be created.

Returns:
Type
KafkaJS.Producer