MCPcopy
hub / github.com/tulios/kafkajs

github.com/tulios/kafkajs @v2.2.4 sqlite

repository ↗ · DeepWiki ↗ · release v2.2.4 ↗
1,278 symbols 5,122 edges 768 files 204 documented · 16%
README

npm version npm pre-release version Build Status Slack Channel

Logo

KafkaJS

A modern Apache Kafka® client for Node.js



<a href="https://kafka.js.org/"><strong>Get Started »</strong></a>






<a href="https://kafka.js.org/docs/getting-started" target="_blank">Read the Docs</a>
·
<a href="https://github.com/tulios/kafkajs/issues/new?assignees=&labels=&template=bug_report.md&title=">Report Bug</a>
·
<a href="https://github.com/tulios/kafkajs/issues/new?assignees=&labels=&template=feature_request.md&title=">Request Feature</a>

Table of Contents

About the Project

KafkaJS is a modern Apache Kafka client for Node.js. It is compatible with Kafka 0.10+ and offers native support for 0.11 features.

KAFKA is a registered trademark of The Apache Software Foundation and has been licensed for use by KafkaJS. KafkaJS has no affiliation with and is not endorsed by The Apache Software Foundation.

Sponsors ❤️

Upstash: Serverless Kafka

  • True Serverless Kafka with per-request-pricing
  • Managed Apache Kafka, works with all Kafka clients
  • Built-in REST API designed for serverless and edge functions
  • Start for free in 30 seconds!
Logo

Get help directly from a KafkaJS developer

  • Become a Github Sponsor to have a video call with a KafkaJS developer
  • Receive personalized support, validate ideas or accelerate your learning
  • Save time and get productive sooner, while supporting KafkaJS!
  • See support options!

To become a sponsor, reach out in our Slack community to get in touch with one of the maintainers. Also consider becoming a Github Sponsor by following any of the links under "Sponsor this project" in the sidebar.

Features

  • Producer
  • Consumer groups with pause, resume, and seek
  • Transactional support for producers and consumers
  • Message headers
  • GZIP compression
  • Snappy, LZ4 and ZSTD compression through pluggable codecs
  • Plain, SSL and SASL_SSL implementations
  • Support for SCRAM-SHA-256 and SCRAM-SHA-512
  • Support for AWS IAM authentication
  • Admin client

Getting Started

npm install kafkajs
# yarn add kafkajs

Usage

const { Kafka } = require('kafkajs')

const kafka = new Kafka({
  clientId: 'my-app',
  brokers: ['kafka1:9092', 'kafka2:9092']
})

const producer = kafka.producer()
const consumer = kafka.consumer({ groupId: 'test-group' })

const run = async () => {
  // Producing
  await producer.connect()
  await producer.send({
    topic: 'test-topic',
    messages: [
      { value: 'Hello KafkaJS user!' },
    ],
  })

  // Consuming
  await consumer.connect()
  await consumer.subscribe({ topic: 'test-topic', fromBeginning: true })

  await consumer.run({
    eachMessage: async ({ topic, partition, message }) => {
      console.log({
        partition,
        offset: message.offset,
        value: message.value.toString(),
      })
    },
  })
}

run().catch(console.error)

Learn more about using KafkaJS on the official site!

Read something on the website that didn't work with the latest stable version?
Check the pre-release versions - the website is updated on every merge to master.

Contributing

KafkaJS is an open-source project where development takes place in the open on GitHub. Although the project is maintained by a small group of dedicated volunteers, we are grateful to the community for bug fixes, feature development and other contributions.

See Developing KafkaJS for information on how to run and develop KafkaJS.

Help wanted 🤝

We welcome contributions to KafkaJS, but we also want to see a thriving third-party ecosystem. If you would like to create an open-source project that builds on top of KafkaJS, please get in touch and we'd be happy to provide feedback and support.

Here are some projects that we would like to build, but haven't yet been able to prioritize:

Contact 💬

Join our Slack community

License

See LICENSE for more details.

Acknowledgements

Apache Kafka and Kafka are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries. KafkaJS has no affiliation with the Apache Software Foundation.

Extension points exported contracts — how you extend this code

EachMessagePayload (Interface)
(no doc) [2 implementers]
types/index.d.ts
KafkaConfig (Interface)
(no doc)
types/index.d.ts
ISocketFactoryArgs (Interface)
(no doc)
types/index.d.ts
OauthbearerProviderResponse (Interface)
(no doc)
types/index.d.ts
ProducerConfig (Interface)
(no doc)
types/index.d.ts

Core symbols most depended-on inside this repo

newLogger
called by 364
testHelpers/index.js
map
called by 311
src/network/connectionPool.js
secureRandom
called by 289
scripts/waitForKafka.js
connect
called by 225
src/broker/index.js
createCluster
called by 215
testHelpers/index.js
toString
called by 156
src/utils/long.js
writeInt32
called by 149
src/protocol/encoder.js
encode
called by 145
types/index.d.ts

Shape

Function 655
Method 396
Class 157
Interface 62
Enum 8

Languages

TypeScript100%
Java1%

Modules by API surface

types/index.d.ts129 symbols
src/errors.js94 symbols
src/broker/index.js40 symbols
src/protocol/encoder.js37 symbols
testHelpers/index.js36 symbols
src/utils/long.js35 symbols
src/admin/index.js35 symbols
src/protocol/decoder.js33 symbols
src/consumer/consumerGroup.js32 symbols
src/consumer/offsetManager/index.js28 symbols
src/network/connection.js27 symbols
src/cluster/index.js25 symbols

Dependencies from manifests, versioned

@types/jest27.4.0 · 1×
@types/node12.0.8 · 1×
@typescript-eslint/typescript-estree1.10.2 · 1×
docusaurus1.13.0 · 1×
eslint6.8.0 · 1×
eslint-config-prettier6.0.0 · 1×
eslint-config-standard13.0.1 · 1×
eslint-plugin-import2.18.2 · 1×
eslint-plugin-jest26.1.0 · 1×
eslint-plugin-node11.0.0 · 1×
eslint-plugin-promise4.2.1 · 1×

For agents

$ claude mcp add kafkajs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact