从Kafka 0.11.0.1中的_transaction_state主题读取数据

问题描述 投票:4回答:2

我想读取事务的元数据(Kafka 0.11.0.1支持),以便我可以弄清楚是否已提交特定事务ID的事务。目前我从_transactional_state主题获取密钥和值,但它采用某种编码格式。下面是我在查询__transaction_state主题时收到的一些相同的键/值:key = 10000000mmm,value = ����+' )

apache-kafka kafka-consumer-api messagebroker string-decoding
2个回答
4
投票

您可以在TransactionLogMessageParser文件中查看kafka/tools/DumpLogSegments.scala类的源代码作为示例。它使用来自readTxnRecordValue类的TransactionLog函数。可以通过同一类的readTxnRecordKey函数检索此函数的第一个参数。


0
投票

就像在Kafka how to read from __consumer_offsets topic做的那样

echo "exclude.internal.topics=false" > consumer.config

kafka-console-consumer --consumer.config consumer.config --formatter "kafka.coordinator.transaction.TransactionLog\$TransactionLogMessageFormatter" --bootstrap-server localhost:9092 --topic __transaction_state --from-beginning

© www.soinside.com 2019 - 2024. All rights reserved.