kafka-streams icon indicating copy to clipboard operation
kafka-streams copied to clipboard

Ignoring element in stream

Open hamid512 opened this issue 4 years ago • 1 comments

how i prevent sending empty string '' if number is odd, like prevent .to from running and just move to next stream data? if defeats the purpose of multiple branching topics for me my code

`const checkforOdd = (kafkaMessage) => { const value = kafkaMessage.value.toString("utf8"); // console.log(value) if(!(parseInt(value) % 2 == 0)){ return value }else{ return '' }

}; const checkforEven = (kafkaMessage) => { const value = kafkaMessage.value.toString("utf8"); if(parseInt(value) % 2 == 0){

    return value
 }
 else{
      return ''
 }

};

const kafkaStreams = new KafkaStreams(config);

kafkaStreams.on("error", (error) => { console.log("Error occured:", error.message); });

const stream = kafkaStreams.getKStream('test-topic'); const [one$, two$] = stream .branch([() => true, () => true]);

const producerPromiseOne = one$ .map(checkforOdd) .to("odd");

const producerPromiseTwo = two$ .map(checkforEven) .to("even");`

hamid512 avatar Sep 11 '20 17:09 hamid512

@rsilvestre @elmarx @crcastle @drublic

hamid512 avatar Sep 11 '20 17:09 hamid512