You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@confluentinc/kafka-javascript

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@confluentinc/kafka-javascript

Node.js bindings for librdkafka

0.1.15-devel
Source
npmnpm
Version published
Weekly downloads
161K
8.44%
Maintainers
2
Weekly downloads
 
Created
Source

Confluent's Javascript Client for Apache KafkaTM

confluent-kafka-javascript is Confluent's JavaScript client for Apache Kafka and the Confluent Platform. This is an early access library. The goal is to provide an highly performant, reliable and easy to use JavaScript client that is based on node-rdkafka yet also API compatible with KafkaJS to provide flexibility to users and streamline migrations from other clients.

This library leverages the work and concepts from two popular Apache Kafka JavaScript clients: node-rdkafka and KafkaJS. The core is heavily based on the node-rdkafka library, which uses our own librdkafka library for core client functionality. However, we leverage a promisified API and a more idiomatic interface, similar to the one in KafkaJS, making it easy for developers to migrate and adopt this client depending on the patterns and interface they prefer. This library currently uses librdkafka based off of the master branch.

This library is currently in early access and not meant for production use

This library is in active development, pre-1.0.0, and it is likely to have many breaking changes.

For this early-access release, we aim to get feedback from JavaScript developers within the Apache Kafka community to help meet your needs. Some areas of feedback we are looking for include:

  • Usability of the API compared to other clients
  • Migration experience from the node-rdkafka and KafkaJs
  • Overall quality and reliability

We invite you to raise issues to highlight any feedback you may have.

Within the early-access, only basic produce and consume functionality as well as the ability to create and delete topics are supported. All other admin client functionality is coming in future releases. See INTRODUCTION.md for more details on what is supported.

To use Schema Registry, use the existing kafkajs/confluent-schema-registry library that is compatible with this library. For a simple schema registry example, see sr.js. DISCLAIMER: Although it is compatible with confluent-kafka-javascript, Confluent does not own or maintain kafkajs/confluent-schema-registry, and the use and functionality of the library should be considered "as is".

Requirements

The following configurations are supported for this early access preview:

  • Any supported version of Node.js (The two LTS versions, 18 and 20, and the latest versions, 21 and 22).
  • Linux (x64 and arm64) - both glibc and musl/alpine.
  • macOS - arm64/m1.
  • Windows - x64 (experimentally available in EA).

A supported version of Python must be available on the system for the installation process. This is required for the node-gyp build tool..

Installation on any of these platforms is meant to be seamless, without any C/C++ compilation required.

$ npm install @confluentinc/kafka-javascript

Yarn and pnpm support is experimental.

Getting Started

Below is a simple produce example for users migrating from KafkaJS.

// require('kafkajs') is replaced with require('@confluentinc/kafka-javascript').KafkaJS.
const { Kafka } = require("@confluentinc/kafka-javascript").KafkaJS;

async function producerStart() {
    const kafka = new Kafka({
        kafkaJS: {
            brokers: ['<fill>'],
            ssl: true,
            sasl: {
                mechanism: 'plain',
                username: '<fill>',
                password: '<fill>',
            },
        }
    });

    const producer = kafka.producer();

    await producer.connect();

    console.log("Connected successfully");

    const res = []
    for (let i = 0; i < 50; i++) {
        res.push(producer.send({
            topic: 'test-topic',
            messages: [
                { value: 'v222', partition: 0 },
                { value: 'v11', partition: 0, key: 'x' },
            ]
        }));
    }
    await Promise.all(res);

    await producer.disconnect();

    console.log("Disconnected successfully");
}

producerStart();

An in-depth reference may be found at INTRODUCTION.md.

Contributing

Bug reports and early-access feedback is appreciated in the form of Github Issues. For guidelines on contributing please see CONTRIBUTING.md

Keywords

kafka

FAQs

Package last updated on 17 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts