Skip to content
Advertisement

Kafka consumer showing numbers in unreadable format

I am trying out the kafka streaming. I am reading messages from one topic and doing groupByKey and then doing the count of groups. But the problem is that the messages count is coming as unreadable “boxes”.

If I run the console consumer these are coming as empty strings

This is the WordCount code I wrote

JavaScript

This is the output I am getting in the consumer. It is there on the right side in image

Consumer output

I had tried casting the long to long again to see if it works. But it’s not working

I am attaching the consumer code too if it helps.

JavaScript

Any help is appreciated. Thanks in advance.

Advertisement

Answer

The message value you’re writing with Kafka Streams is a Long, and you’re consuming it as a String.

If you make the following changes to your Consumer class, you’ll be able to see the count printed correctly to stdout:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement