unable to consume specific amount of messages without waiting with a setTimeout
See original GitHub issueEnvironment Information
- OS [e.g. Mac, Arch, Windows 10]: RedHat
- Node Version [e.g. 8.2.1]: 10.6.0
- NPM Version [e.g. 5.4.2]: 6.1.0
- C++ Toolchain [e.g. Visual Studio, llvm, g++]:
- node-rdkafka version [e.g. 2.3.3]: 2.3.2
// Non-flowing mode
consumer.connect();
consumer
.on('ready', function() {
consumer.subscribe(['librdtesting-01']);
// Read only 1000 messages
consumer.consume(1000); // <---------- This is not working...
})
.on('data', function(data) {
console.log('Message found! Contents below.');
console.log(data.value.toString());
});
If i’m replacing the line that I’ve marked above with the following, then it does work:
setTimeout(() => consumer.consume(1000), 60000); // <-- this is working..
Could this be related to node-rdkafka
? or is it something that has to do with my kafka configuration?
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Is setTimeout with no delay the same as executing the function ...
The reason is that setTimeout removes the function from the execution queue ... The time, in milliseconds that the timer should wait before...
Read more >setTimeout() - Web APIs | MDN
The global setTimeout() method sets a timer which executes a function or specified piece of code once the timer expires.
Read more >setTimeout not triggering when unit testing #3211 - GitHub
It won't log the message, because Jest buffers all console calls so they can be displayed after test results reporters, and since setTimeout() ......
Read more >Scheduling: setTimeout and setInterval
To cancel the execution, we should call clearTimeout/clearInterval with the value returned by setTimeout/setInterval .
Read more >Using setTimeout in React components (including hooks)
Can't call "this.setState" on an unmounted component. To clear a timeout, we need to call clearTimeout with the returned value of setTimeout :....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Multiple people have the same problem (myself included). This should not be closed.
Is there not an error event emitted? I am seeing something very similar, but error is
null
and the messages array is empty. It seems likeready
is being fired before the consumer has fetched partition offsets, according to the logs when i setdebug
to `consumer. Also, it appears that the offset is being incremented even though I am not receiving the messages through the data or consume callbacks