start.js
function(req, topic, messages){
    payloads[0]['topic'] = topic
    payloads[0]['messages']= JSON.stringify(messages);
    console.log(payloads[0]['messages']);
    setTimeout(function () {
        producer.send(payloads, function (err, data) {
            if(err){
                console.log(err);
            }
        });
        producer.on('error', function (err) {
            console.log(err);
        });
    }, 1000);
}
function(req, topic, messages){
    payloads[0]['topic'] = topic
    payloads[0]['messages']= JSON.stringify(messages);
    console.log(payloads[0]['messages']);
    setTimeout(function () {
        producer.send(payloads, function (err, data) {
            if(err){
                console.log(err);
            }
        });
        producer.on('error', function (err) {
            console.log(err);
        });
    }, 1000);
}
function ( req , topic , messages ) { payloads [ 0 ] [ 'topic' ] = topic payloads [ 0 ] [ 'messages' ] = JSON . stringify ( messages ) ; console . log ( payloads [ 0 ] [ 'messages' ] ) ; setTimeout ( function ( ) { producer . send ( payloads , function ( err , data ) { if ( err ) { console . log ( err ) ; } } ) ; producer . on ( 'error' , function ( err ) { console . log ( err ) ; } ) ; } , 1000 ) ; }
publish message to kafka.
publish message to kafka .