@halcyon-agile/adonis-kafka
v0.3.3
Published
Kafka Provider for AdonisJs
Downloads
48
Readme
API is based on https://github.com/Frubana/adonis-kafka and depends on kafkajs
Getting Started
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
})