Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.post('/send-message', function(req, res) {
var key = req.body.key;
var message = req.body.message;
log('Sending message with key %s and body %s', key, message);
producer.send(
[
{
topic: 'test',
messages: new kafka.KeyedMessage(key, message)
}
],
function(err) {
if (err) {
log('Failed to send message with key %s', key, err);
res.status(500).send('Failed to send message');
return;
}
request('http://127.0.0.1:' + agentPort)
.then(function() {
res.sendStatus(200);
})
.catch(function(err2) {
log(err2);
res.sendStatus(500);
});
return this.getPartitionForKey(partitionKey).then(partition => {
return {
topic,
partition,
messages: new KeyedMessage(identifier, JSON.stringify(object)),
attributes: compressionType
};
});
}
entries.map(item => ({
topic: this._topic,
messages: new KeyedMessage(item.key, JSON.stringify(item)),
key: item.key,
})) :
entries.map(item => ({