import * as kafka from 'kafka-node'; //import {getConsumer} from './message'
export function receiveMessage(): any { const _that = this; let topicName = 'message-chinguyen'; let produceTopic = topicName; let kafkaConsumer = kafka.Consumer; let Client = kafka.KafkaClient; let client = new Client({ kafkaHost: 'localhost:9092' }) let consumer = new kafkaConsumer(client, [{ topic: produceTopic }], { autoCommit: false, fetchMaxWaitMs: 1000, fetchMaxBytes: 1024 * 1024 }) consumer.on('message', function(message) { console.log(message); }); consumer.on('error', function(err) { console.log('error', err); }); }