AdonisJS
Adonis Kafka provides an easy way to start using Kafka.
API is based on https://github.com/Frubana/adonis-kafka and depends on kafkajs
Getting Started
A Kafka provider for API is based on https://github.com/Frubana/adonis-kafka and depends on kafkajs
Let's start by installing the package in our project.
Yarn:
yarn add @halcyon-agile/adonis-kafka
NPM:
npm install @halcyon-agile/adonis-kafka
Setup
You can configure the project by running the following command:
node ace invoke @halcyon-agile/adonis-kafka
Adding Topics
node ace make:prldfile kafka
// start/kafka.ts
import Kafka from '@ioc:Kafka'
// Callback function
Kafka.on('topic_name', async (data, commit) => {
commit() // For successful transaction
commit(false) // For failed transaction
})
// Multiple topics
Kafka.on('topic_name_1,topic_name_2,topic_name_3', async (data, commit) => {
commit() // For successful transaction
commit(false) // For failed transaction
})