Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can i consumer message one by one ? #349

Closed
sunkuo opened this issue Apr 6, 2016 · 3 comments
Closed

Can i consumer message one by one ? #349

sunkuo opened this issue Apr 6, 2016 · 3 comments
Labels

Comments

@sunkuo
Copy link

sunkuo commented Apr 6, 2016

Now , i found that kafka-node will receive message on "message" event . But i want to handle a message ,then to fetch the next message ,not auto fetch . How to make it ?

@hyperlink
Copy link
Collaborator

Each fetch can grab more than one message so the only way to process one message at a time is to pause() after the first message and then use something like async.queue to process one at a time and resume() after finished processing all the messages.

@sunkuo
Copy link
Author

sunkuo commented Apr 8, 2016

Thank you for your Suggestion. I found that when i call pause() as soon as i receive the first message , But i still receive some other message on event "message" . Can i just receive one message with the help of pause and resume ?

@hyperlink
Copy link
Collaborator

pause and resume controls the fetch loop. it doesn't provide fine grained control with message events. If you are sure of the size of your messages you can tweak the fetch size to limit the number of messages per fetch but it could be a tricky thing to get right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants