File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ def print_usage_and_exit(program_name):
52
52
# Consumer configuration
53
53
# See https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md
54
54
conf = {'bootstrap.servers' : broker , 'group.id' : group , 'session.timeout.ms' : 6000 ,
55
- 'auto.offset.reset' : 'earliest' }
55
+ 'auto.offset.reset' : 'earliest' , 'enable.auto.offset.store' : False }
56
56
57
57
# Check to see if -T option exists
58
58
for opt in optlist :
@@ -102,6 +102,10 @@ def print_assignment(consumer, partitions):
102
102
(msg .topic (), msg .partition (), msg .offset (),
103
103
str (msg .key ())))
104
104
print (msg .value ())
105
+ # Store the offset associated with msg to a local cache.
106
+ # Stored offsets are committed to Kafka by a background thread every 'auto.commit.interval.ms'.
107
+ # Explicitly storing offsets after processing gives at-least once semantics.
108
+ c .store_offsets (msg )
105
109
106
110
except KeyboardInterrupt :
107
111
sys .stderr .write ('%% Aborted by user\n ' )
You can’t perform that action at this time.
0 commit comments