How to use the kafka-node.KeyedMessage function in kafka-node

To help you get started, we’ve selected a few kafka-node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github instana / nodejs-sensor / test / tracing / messaging / kafka / producer.js View on Github external
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);
        });
github nodefluent / node-sinek / lib / kafka / Publisher.js View on Github external
return this.getPartitionForKey(partitionKey).then(partition => {
      return {
        topic,
        partition,
        messages: new KeyedMessage(identifier, JSON.stringify(object)),
        attributes: compressionType
      };
    });
  }
github scality / backbeat / lib / BackbeatProducer.js View on Github external
entries.map(item => ({
                      topic: this._topic,
                      messages: new KeyedMessage(item.key, JSON.stringify(item)),
                      key: item.key,
                  })) :
                  entries.map(item => ({