因log檔出問題,這篇重建整個topics
透過刪除以下data目錄下的兩個資料挾:
確認目前offset狀態
在次進入group為my-first-app的consumer
離開再重進
回到原標題,我想看已經被接收過的訊息該怎麼辦
進行確認group的指令
kafka-consumer-groups
其中有
將offset拉到最初始訊息的位置
kafka-consumer-groups --bootstrap-server localhost:9092 --group my-first-app --reset-offsets --to-earliest
kafka-consumer-groups --bootstrap-server localhost:9092 --group my-first-app --reset-offsets --to-earliest --execute
所以正確的指令如下
kafka-consumer-groups --bootstrap-server localhost:9092 --group my-first-app --reset-offsets --to-earliest --execute --topic first_topic
此時次執行這個consumer group時會看到全部舊有的所有訊息!
進入同一個group的consumer console
kafka-console-consumer --bootstrap-server localhost:9092 --topic first_topic --group my-first-app
透過指令再次看到group的describe資料
kafka-consumer-groups --bootstrap-server localhost:9092 --describe --group my-first-app
接著也嘗試另一個叫shift-by的指令(且指定偏移量2)
kafka-consumer-groups --bootstrap-server localhost:9092 --group my-first-app --reset-offsets --shift-by 2 --execute --topic first_topic
試著改-2偏移
再次進到同一個gorup的consumer console