npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kafka-pub-sub

v1.1.7

Published

An application which is designed based on apache kafka pub-sub.

Downloads

23

Readme

Gitpod

NPM VersionNPM Monthly Downloads

Last Commit Language Most Used Implementations Repository Size

Forks Stars Watches

Author GitHub

kafka-pub-sub is designed based on KafkaJS with the support of stream processing that enables applications to publish, consume and process high volumes of record streams in a fast and durable way.

🔖 Table Of Contents


  • NPM/Yarn LTS
  • NodeJs

Back To The Top


💻 Desktop

If you use Linux, try run commands bellow as sudo

npm i kafka-pub-sub

or

yarn add kafka-pub-sub

Back To The Top


Project stucture

Note: Create NodeJS environment in both service-1 and service-2 and create server using your favourite NodeJS framewwork.

service-1/server.js

const ProduceEvent = require('kafka-pub-sub/ProduceEvent');

app.post('/api', async (req, res) => {
    const fakeData = {
        Name: "Md. Muhtasim Fuad Fahim",
        Email: "[email protected]",
    };

    const headers = { 
        'correlation-id': `1-${Date.now()}`,
        'system-id': 'my-system-id'
    };
    const producedEvent = await ProduceEvent('TEST_TOPIC', 'TEST_EVENT', fakeData, headers)
    console.log(producedEvent)

    return res.status(200).send("Done!");
});

service-2/server.js

const ConsumeEvent = require('kafka-pub-sub/ConsumeEvent');

(async function consumedEvent() {
    const consumedData = await ConsumeEvent('TEST_TOPIC')
    console.log(consumedData);
})();

service-1/.env & service-2/.env

KAFKA_CLIENT_ID=test-client
KAFKA_BROKER_URL=localhost:9092
KAFKA_GROUP_ID=test-group

sample docker-compose.yml

version: '2.1'
services:
  zookeeper:
    hostname: zookeeper
    container_name: zookeeper
    image: confluentinc/cp-zookeeper:latest
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
  kafka:
    hostname: kafka
    container_name: kafka
    image: confluentinc/cp-kafka:latest
    depends_on:
      - zookeeper
    ports:
      - 9092:9092
    environment:
      KAFKA_BROKER_URL_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
      KAFKAJS_NO_PARTITIONER_WARNING: 1
      KAFKA_NUM_PARTITIONS: '6'

Back To The Top


  • Fork it 😎
  • Clone forked repository: git clone https://github.com/username/forked-name.git
  • Install the dependencies from root directory: npm install
  • Rename .env.example to .env
  • Now run: npm run test & see the results 😎

  • Fork it 😎
  • Create a feature branch: git checkout -b my-feature
  • Add your changes: git add .
  • Commit your changes: git commit -m 'My new feature'
  • Push to the branch: git push origin my-feature
  • Submit a pull request

Back To The Top


Alt

Back To The Top


🤓 Md. Muhtasim Fuad Fahim [email protected]

Back To The Top


Copyright © 2023 Md. Muhtasim Fuad Fahim

This project is licensed by MIT License.

Back To The Top