kafka-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Satendra Pratap Singh <sameerp...@gmail.com>
Subject #Getting null values in kafka while pushing data from nodejs
Date Thu, 13 Dec 2018 05:36:31 GMT
Hi All,

I am pushing data from nodejs server to kafka topic when i consume this
topic getting null values. i have checked javascript producer its working
fine and send data Json data to kafka. any help would be appreciated. i
have posted my producer code here.

var kafka = require('kafka-node');
var client = new kafka.Client('localhost:2181');
    var HighLevelProducer = kafka.HighLevelProducer;
    var producer = new kafka.HighLevelProducer(client);
    var KeyedMessage = kafka.KeyedMessage;
    var topicName = 'test1';
const buffer = new Buffer.from(JSON.stringify(data)); // i am getting data
from source in data variable.
            console.log('get into postdata');
            payloads = [{topic:topicName, message:buffer}];
               console.log('kafka producer is connected and ready.');
             producer.send(payloads, function(error, result) {
             console.info('Sent payload to Kafka: ', payloads);
            if (error) {
                console.error(error);
            } else {
                console.log('result: ', result)
            }
              });


here is node server logs:

data arrived

get into postdata

kafka producer is connected and ready.

Sent payload to Kafka:  [ { topic: 'test1',

    message:

     <Buffer 7b 22 41 6c 74 65 72 6e 61 74 65 55 6e 69 71 75 65 4b 65 79 22
3a 22 22 2c 22 44 6f 77 6e 6c 6f 61 64 65 64 44 65 76 69 63 65 55 6e 69 71
75 65 4b 65 ... 1564 more bytes>,

    partition: 0,

    attributes: 0 } ]

result:  { test1: { '0': 33 } }

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message