@@ -43,7 +43,7 @@ private static void generalConsumerAutoCommit() {
43
43
//间隔100ms,拉取一次数据
44
44
ConsumerRecords <String , String > records = consumer .poll (100 );
45
45
for (ConsumerRecord <String , String > record : records ) {
46
- System .out .println (String .format ("topic = %s, partition = %s, key = %s" , record .topic (), record .partition (), record .offset (), record .key (), record .value ()));
46
+ System .out .println (String .format ("topic = %s, partition = %s, offset = %s, key = %s, value = %s" , record .topic (), record .partition (), record .offset (), record .key (), record .value ()));
47
47
if (record .value ().equals ("done" )) {
48
48
flag = false ;
49
49
}
@@ -70,7 +70,7 @@ public static void generalConsumeMessageSyncCommit() {
70
70
//间隔100ms,拉取一次数据
71
71
ConsumerRecords <String , String > records = consumer .poll (100 );
72
72
for (ConsumerRecord <String , String > record : records ) {
73
- System .out .println (String .format ("topic = %s, partition = %s, key = %s" , record .topic (), record .partition (), record .offset (), record .key (), record .value ()));
73
+ System .out .println (String .format ("topic = %s, partition = %s, offset = %s, key = %s, value = %s" , record .topic (), record .partition (), record .offset (), record .key (), record .value ()));
74
74
if (record .value ().equals ("done" )) {
75
75
flag = false ;
76
76
}
@@ -99,7 +99,7 @@ private static void generalConsumeMessageAsyncCommit() {
99
99
//间隔100ms,拉取一次数据
100
100
ConsumerRecords <String , String > records = consumer .poll (100 );
101
101
for (ConsumerRecord <String , String > record : records ) {
102
- System .out .println (String .format ("topic = %s, partition = %s, key = %s" , record .topic (), record .partition (), record .offset (), record .key (), record .value ()));
102
+ System .out .println (String .format ("topic = %s, partition = %s, offset = %s, key = %s, value = %s" , record .topic (), record .partition (), record .offset (), record .key (), record .value ()));
103
103
if (record .value ().equals ("done" )) {
104
104
flag = false ;
105
105
}
@@ -124,7 +124,7 @@ public static void generalConsumeMessageAsyncCommitWithCallback() {
124
124
//间隔100ms,拉取一次数据
125
125
ConsumerRecords <String , String > records = consumer .poll (100 );
126
126
for (ConsumerRecord <String , String > record : records ) {
127
- System .out .println (String .format ("topic = %s, partition = %s, key = %s" , record .topic (), record .partition (), record .offset (), record .key (), record .value ()));
127
+ System .out .println (String .format ("topic = %s, partition = %s, offset = %s, key = %s, value = %s" , record .topic (), record .partition (), record .offset (), record .key (), record .value ()));
128
128
if (record .value ().equals ("done" )) {
129
129
flag = false ;
130
130
}
@@ -152,7 +152,7 @@ public static void mixSyncAndsyncCommit() {
152
152
//间隔100ms,拉取一次数据
153
153
ConsumerRecords <String , String > records = consumer .poll (100 );
154
154
for (ConsumerRecord <String , String > record : records ) {
155
- System .out .println (String .format ("topic = %s, partition = %s, key = %s" , record .topic (), record .partition (), record .offset (), record .key (), record .value ()));
155
+ System .out .println (String .format ("topic = %s, partition = %s, offset = %s, key = %s, value = %s" , record .topic (), record .partition (), record .offset (), record .key (), record .value ()));
156
156
}
157
157
//异步提交
158
158
consumer .commitAsync ();
0 commit comments