Code Monkey home page Code Monkey logo

Comments (8)

haio avatar haio commented on August 25, 2024

You should try the latest version, fromBeginning is no longer support. If you want consume topic from the exact offset, you should set fromOffset true and also set the offset in payload, for example:

var payloads = [{ topic: 't', partition: 0, offset: offset_you_want }];
var consumer = new Consumer( client, payloads, { fromOffset: true });

If you just want consume the current message, the default settings should satisfy you.

from kafka-node.

ed-sullivation avatar ed-sullivation commented on August 25, 2024

Using the default settings causes

this.consumer.on('message', function (message) {
            console.log("Consumer Message",message);
 }); 

to continuously output the first message once a message exists in the partition:

Consumer Message 
{ 
topic: 'event-bus',
  value: '{type:\'PageView\',body:[]}',
  offset: 0,
  partition: 0,
  key: -1 }

from kafka-node.

haio avatar haio commented on August 25, 2024

Yes, what you see is the expected behavior of consumer with default settings. By default, consumer will consume message from the last commited offset when it start and consume whatever incoming message after start, it will automatically commit the offset too. If this not your use case, please explain here ^_^

from kafka-node.

ed-sullivation avatar ed-sullivation commented on August 25, 2024

I guess I was only expecting to consume each message once from the callback of Consumer.on, not have the last message consumed in a continuous loop. How can I block the consumption after one message until a new message is commited?

from kafka-node.

haio avatar haio commented on August 25, 2024

This seems a bug of consumer, I will look into it.

from kafka-node.

haio avatar haio commented on August 25, 2024

It should be fixed in this commit: fac599d
Please test it.

from kafka-node.

ed-sullivation avatar ed-sullivation commented on August 25, 2024

The !== undefined addition to lib/consumer.js fixed it! Thanks!

from kafka-node.

ed-sullivation avatar ed-sullivation commented on August 25, 2024

The !== undefined addition to lib/consumer.js fixed it! Thanks!

from kafka-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.