[英]Unable to read messages from Kafka topic using console consumer
I created stream1
in KSQL
(version 5.0 Beta) with a backing topic topic1
and avro
schema.我创建
stream1
在KSQL
与背衬主题(版本5.0 Beta版) topic1
和avro
模式。 I am able to read all messages on topic1
using kafka-avro-console-consumer
.我能够读取所有的消息
topic1
使用kafka-avro-console-consumer
。
I then created stream2
in KSQL
that's based on stream1
but with json
format for the messages and backing topic named topic2
.然后,我创建
stream2
在KSQL
这是基于stream1
,但用json
用于指定信息和后盾主题格式topic2
。 I am able to read all the messages on topic2
using kafka-console-consumer
我能够使用
kafka-console-consumer
读取topic2
上的所有消息
I created stream3
in KSQL
based on stream2
with json
message format and backing topic named topic3
.我创建
stream3
在KSQL
基于stream2
用json
消息格式和后盾主题命名topic3
。 However, I am unable to read the messages on topic3
using kafka-console-consumer
.但是,我无法使用
kafka-console-consumer
读取topic3
上的消息。
Using kafkacat
I get offsets on various partitions on topic3
but none of the actual messages is being printed.使用
kafkacat
我在topic3
各个分区上获得偏移量,但没有打印任何实际消息。
It looks likes the messages are in the topic but neither kafkacat
not kafka-console-consumer
is able to print it.看起来消息在主题中,但
kafkacat
kafka-console-consumer
都无法打印它。
Tried using --from-beginning
and --offset earliest --partition 0
with no luck.尝试使用
--offset earliest --partition 0
--from-beginning
和--offset earliest --partition 0
没有运气。
Here are the KSQL statements这里是 KSQL 语句
CREATE STREAM stream1(p_id STRING, location STRING, u_id STRING, r_id STRING, b_id STRING, recorded_dtm STRING,
v_type STRING, value STRING) WITH (kafka_topic='topic1', value_format='AVRO');
CREATE STREAM stream2 WITH (KAFKA_topic='topic2', VALUE_FORMAT='json', TIMESTAMP='RECORDED_TIMESTAMP')
AS select P_ID+'-'+LOCATION+'-'+U_ID+'-'+R_ID+'-'+B_ID+'-'+V_TYPE as PARTITION_KEY,
LOCATION, U_ID, R_ID, V_TYPE, B_ID, STRINGTOTIMESTAMP(recorded_dtm, 'yyyyMMddHHmmss') as RECORDED_TIMESTAMP,
P_ID, VALUE, RECORDED_DTM,'NM' as DATA_TYPE
FROM stream1 PARTITION BY PARTITION_KEY;
CREATE STREAM stream3 WITH (KAFKA_topic='topic3', VALUE_FORMAT='json', TIMESTAMP='RECORDED_TIMESTAMP')
AS select PARTITION_KEY, LOCATION, U_ID, R_ID, V_TYPE, B_ID, RECORDED_TIMESTAMP,
P_ID, VALUE, RECORDED_DTM FROM stream2 PARTITION BY PARTITION_KEY;
Additional info附加信息
In ksql
if I run SET 'auto.offset.reset'='earliest';
在
ksql
如果我运行SET 'auto.offset.reset'='earliest';
and run select * from stream1 limit 5;
并运行
select * from stream1 limit 5;
or select * from stream2 limit 5
I see records printed but select * from stream3 limit 5
does not return any records.或
select * from stream2 limit 5
我看到记录打印但select * from stream3 limit 5
不返回任何记录。
If I run describe extended stream3
I get如果我运行
describe extended stream3
我得到
total-messages: 212消息总数:212
which happens to be the number of messages I sent to topic1这恰好是我发送到 topic1 的消息数
The root cause was the Timestamp
on STREAM3
The value for recorded_dtm
column sent to messages on topic1 was earlier than the log.retention.hours
value set in the kafka server.properties
.根本原因是
Timestamp
上STREAM3
为值recorded_dtm
发送到上TOPIC1消息柱早于是log.retention.hours
中设置的值kafka server.properties
。
Our log.retention.hours
value is set to 24 hours
and the recorded_dtm values were earlier than 24 hours.我们的
log.retention.hours
值设置为24 hours
,而记录的log.retention.hours
值早于 24 小时。 This caused the messages in STREAM3
and topic3
to be immediately removed based in the retention policy.这导致根据保留策略立即删除
STREAM3
和topic3
的消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.