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

ConsumerGroup does not support 'buffer' encoding, corrupts binary data #1131

Closed
mishan opened this issue Dec 3, 2018 · 1 comment
Closed

Comments

@mishan
Copy link
Contributor

mishan commented Dec 3, 2018

Environment

  • Node version: 10.4.0
  • Kafka-node version: 3.0.1
  • Kafka version: 0.10.2

For specific cases also provide

  • Number of Brokers: 1
  • Number partitions for topic: 1

Include Sample Code to reproduce behavior

const { ConsumerGroup } = require('kafka-node');

var options = {
  kafkaHost: 'kafka:9092',
  groupId: 'TestGroup',
};

var consumerGroup = new ConsumerGroup(options, 'mytopic');

consumerGroup.on('message', (message) => {
  // XXX: observe that message.value is not a Buffer
  // there is no option to make it one via ConsumerGroup.
  // binary data is corrupted from the UTF8 conversion
  console.log(typeof message.value);
  console.log(message.value);
});

Output is that message.value is a string. If you use binary encoded data like with AVRO, then you will end up with corrupted data.

Consumer offers an encoding option, but ConsumerGroup does not. It looks like ConsumerGroup needs to include this option and allow it to be passed down.

mishan added a commit to mishan/kafka-node that referenced this issue Dec 4, 2018
This allows binary data to be consumed via ConsumerGroup without corruption, resolving issue SOHU-Co#1131
@TysonAndre
Copy link

TysonAndre commented Dec 4, 2018

It looks like it exists, and a followup comment on another ticket says it's poorly documented, but I'm not familiar with this codebase. See #470 (comment)

I agree with including it in the README. Changing the code makes easier to read in my opinion, but doesn't seem absolutely necessary for calling code to work properly

Aside: It's also already mentioned in ConsumerGroupOptions of types/index.d.ts, so types/index.d.ts doesn't need to be updated.

hyperlink pushed a commit that referenced this issue Dec 7, 2018
This allows binary data to be consumed via ConsumerGroup without corruption, resolving issue #1131
@mishan mishan closed this as completed Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants