简体   繁体   English

Kafka 消息在消费者中拆分

[英]Kafka Messages are split in consumer

I am new to Kafka.我是卡夫卡的新手。 I am sending a request to REST server and send the response of the request to kafka server as messages.我正在向 REST 服务器发送请求,并将请求的响应作为消息发送给 kafka 服务器。

When i consume the data from consumer the message is split into multiple smaller messages.当我使用来自消费者的数据时,消息被分成多个较小的消息。 How do i avoid this.我该如何避免这种情况。 The response is a JSON row.响应是 JSON 行。 I want each json row to be one message.我希望每个 json 行都是一条消息。 Any help would be appreciated.任何帮助,将不胜感激。 The size of the Json is also not very big. Json 的大小也不是很大。 A json with over 1500 rows is about 2 MB超过 1500 行的 json 大约 2 MB

For eg例如

ConsumerRecord(topic='meetup_sample', partition=0, offset=445386, >timestamp=1530554568191, timestamp_type=0, >key=b'5fa4964b035c072a81fedb93cfca8f0ecb562cf913c69f63efbbf4e799871f05', >value=b':"food-and-drink","topic_name":"Food and Drink"},{"urlkey":"newintown","topic_name":"New In Town"},{"urlkey":"beer","topic_name"', >checksum=None, serialized_key_size=64, serialized_value_size=128) ConsumerRecord(topic='meetup_sample', partition=0, offset=445387, >timestamp=1530554568192, timestamp_type=0, >key=b'1f170ceabf91335d332487ebb0890f0bd0ed69018c618ecc2c789a260d561f43', >value=b':"Beer"},{"urlkey":"game-night","topic_name":"Game Night"},{"urlkey":"happy-hours","topic_name":"Happy Hour"},{"urlkey":"water-s', >checksum=None, serialized_key_size=64, serialized_value_size=128) ConsumerRecord(topic='meetup_sample', partition=0, offset=445386, >timestamp=1530554568191, timestamp_type=0, >key=b'5fa4964b035c072a81fedb93cfca8f0ecb562cf913c69f63efbbf4e799871f05', >value=b'andtop-d'andrink_d:"食物名称:"Food and Drink"},{"urlkey":"newintown","topic_name":"New In Town"},{"urlkey":"beer","topic_name"', >checksum=None, serialized_key_size=64 , serialized_value_size=128) ConsumerRecord(topic='meetup_sample', partition=0, offset=445387, >timestamp=1530554568192, timestamp_type=0, >key=b'1f170ceabf91335d332487ebb0890f0bd0ed69018c618ecc2c789a24b'},>{valueBeerf=60d56} "urlkey":"game-night","topic_name":"游戏之夜"},{"urlkey":"欢乐时光","topic_name":"欢乐时光"},{"urlkey":"water-s ', >checksum=None, serialized_key_size=64, serialized_value_size=128)

Once use fetch.message.max.bytes=2000000 in consumer side一旦在消费者端使用 fetch.message.max.bytes=2000000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM