Skip to content

AtomicKafka/atomicKafkaProducer

Repository files navigation

AtomicKafka_MastHead


AtomicKafka is a lightweight NPM Package developed to simplify the process of establishing bidirectional, real-time data streaming with Apache Kafka in your web-app.
Website  |  Library  |  Demo Apps  |  Featured on Medium

npm GitHub contributors GitHub Repo stars Last Commit NPM

AtomicKafkaProducer

AtomicKafkaProducer demonstrates a functioning standalone Producer microservice built into a React Component. This demo app was built to be used alongside AtomicKafkaConsumer.

If you are running the corresponding Consumer, the Consumer will listen to the data that you produce from your producer app in real time. Try it with your colleagues by setting up a free Confluent Cloud and sharing the API credentials with each to see how AtomicKafka integrates with the cloud!


Getting Started

1. Set up your Kafka service

Docker:

  • If using Docker, use the .yml file provided herein and run in the root directory of this app.

    docker-compose up -d

Confluent Cloud:

  • Follow the steps on Confluent Cloud to create a free account. Obtain the API_ACCESS_KEY, API_ACCESS_SECRET, and BOOTSTRAP_SERVER.
  • Note that if you already have a Kafka instance running from a docker image (e.g. from the Producer demo), you do not need to compose again.

2. Configure .env file

  • Default ports are configured on the local host for the dev-server 9001 and the Kafka broker 3001.
  • Docker .env config: (API_KEY and API_SECRET are intentionally left blank).
    API_KEY=
    API_SECRET=
    KAFKA_BOOTSTRAP_SERVER=localhost:9092
  • Confluent Cloud .env config:
    API_KEY=<API_ACCESS_KEY>
    API_SECRET=<API_ACCESS_SECRET>
    KAFKA_BOOTSTRAP_SERVER=<BOOTSTRAP_SERVER>

3. Install dependencies and build the package

$ npm install
$ npm run build

4. Run the dev server

$ npm run dev

5. OPTIONAL Toggle file system interval production.

The Producer's default behavior accepts user inputs in the fields provided in the web-app. This Producer can also produce data from the file system - salesData.json.

To enable this functionality, do the following in server.js:

  • Comment out the atomicKafkaInstance's socketProduce invocation (line 46):

    //atomicKafkaInstance.socketProduce('postMessage', 'test_topic');
  • Uncomment the invocation of produceMyWay (line 87):

    // Uncomment invocation below to test this app with an endless stream of mock data
    produceMyWay();

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published