最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

在kafka中使用no

IT培训 admin 7浏览 0评论

在kafka中使用no

默认情况下,在no-kafka中有一个暂定配置,默认为3。

return producer.send(messages, {
  retries: {
    attempts: 2,
    delay: {
      min: 100,
      max: 300
    }
  }
});

如何手动拒绝邮件?

var consumer = new Kafka.SimpleConsumer();

// data handler function can return a Promise
var dataHandler = function(messageSet, topic, partition) {
  messageSet.forEach(function(m) {
    const random = Math.floor(Math.random() * 11);
    if (random > 5) {
      console.log(topic, partition, m.offset, m.message.value.toString("utf8"));
    } else {
        // Decline a message
      console.log("Decline a message");
    }
  });
};

return consumer.init().then(function() {
  // Subscribe partitons 0 and 1 in a topic:
  return consumer.subscribe("kafka-test-topic", [0, 1], dataHandler);
});
回答如下:

在send方法调用之后,一个单独的线程负责将这些批记录发送到适当的kafka代理。发送调用后无法取消记录。我们将从代理获得是否已提交消息的响应。

在kafka中使用no

默认情况下,在no-kafka中有一个暂定配置,默认为3。

return producer.send(messages, {
  retries: {
    attempts: 2,
    delay: {
      min: 100,
      max: 300
    }
  }
});

如何手动拒绝邮件?

var consumer = new Kafka.SimpleConsumer();

// data handler function can return a Promise
var dataHandler = function(messageSet, topic, partition) {
  messageSet.forEach(function(m) {
    const random = Math.floor(Math.random() * 11);
    if (random > 5) {
      console.log(topic, partition, m.offset, m.message.value.toString("utf8"));
    } else {
        // Decline a message
      console.log("Decline a message");
    }
  });
};

return consumer.init().then(function() {
  // Subscribe partitons 0 and 1 in a topic:
  return consumer.subscribe("kafka-test-topic", [0, 1], dataHandler);
});
回答如下:

在send方法调用之后,一个单独的线程负责将这些批记录发送到适当的kafka代理。发送调用后无法取消记录。我们将从代理获得是否已提交消息的响应。

与本文相关的文章

发布评论

评论列表 (0)

  1. 暂无评论