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

Writting stream to topic doesn't write #190

Open
axel-sirota opened this issue May 17, 2021 · 1 comment
Open

Writting stream to topic doesn't write #190

axel-sirota opened this issue May 17, 2021 · 1 comment

Comments

@axel-sirota
Copy link

axel-sirota commented May 17, 2021

Hi! Following the wordcount.js example, I mimicked it into the following. Everything works, even if I get the end of the stream and write to a file or log it to console it works as supposed to, but it doesn't publish to another topic. Does that have a bug? Any clues?

const stream = kafkaStreams.getKStream();

stream
  .from("RawTempReadings")
  .filter(kv => parseInt(kv.value, 10) > -50)
  .filter(kv => parseInt(kv.value, 10) < 130)
  .tap(kv => console.log(kv))
  .to("ValidatedTempReadings");

const inputStream = kafkaStreams.getKStream();
inputStream.to("RawTempReadings");

const produceInterval = setInterval(() => {
  inputStream.writeToStream(`${Math.floor(Math.random()* 300)-100}`);
}, 100);

Promise.all([
  stream.start(),
  inputStream.start(),
]).then(() => {
  console.log("started..");
  setTimeout(() => {
      clearInterval(produceInterval);
      console.log("stopped..");
  }, 5000);
});

Node version: v15.13.0
OS: Mac
package.json:

"dependencies": { "kafka-streams": "^5.0.0", "kafkajs": "^1.15.0", "kafkajs-avro": "^1.0.4", "kafkajs-stream": "^0.0.12", "minimist": "^1.2.5", "node-rdkafka": "^2.10.1" } }

@hgill
Copy link

hgill commented May 28, 2021

the .to function defaults to "send" mode which takes either a Buffer or a String. You need to change the mode of .to function to "buffer", which can take a Buffer or an Object.
See this example

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