Return a message to the topic
Opened this issue · 0 comments
rafaelvicio commented
By default in no-kafka there is a tentative configuration that defaults to 3.
return producer.send(messages, {
retries: {
attempts: 2,
delay: {
min: 100,
max: 300
}
}
});
How can I manually decline a message?
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);
});