@@ -125,11 +125,6 @@ class Consumer {
125
125
*/
126
126
#messageCache = null ;
127
127
128
- /**
129
- * Whether the user has enabled manual offset management (stores).
130
- */
131
- #userManagedStores = false ;
132
-
133
128
/**
134
129
* Whether the user has enabled manual offset management (commits).
135
130
*/
@@ -536,20 +531,14 @@ class Consumer {
536
531
rdKafkaConfig [ 'offset_commit_cb' ] = true ;
537
532
rdKafkaConfig [ 'rebalance_cb' ] = this . #rebalanceCallback. bind ( this ) ;
538
533
539
- /* Offset management is different from case to case.
540
- * Case 1: User has changed value of enable.auto.offset.store. In this case, we respect that.
541
- * Case 2: automatic committing is on. In this case, we turn off auto.offset.store and store offsets manually.
542
- * this is necessary for cache invalidation and management, as we want to put things into the store
543
- * after eachMessage is called, and not on consume itself.
544
- * Case 3: automatic committing is off. In this case, we turn off auto.offset.store too. Since the user might
545
- * call an empty commit() and expect things to work properly (ie. the right offsets be stored).
546
- * All this works out a singular, simple condition.
547
- */
548
- if ( ! Object . hasOwn ( this . #userConfig, 'enable.auto.offset.store' ) ) {
549
- rdKafkaConfig [ 'enable.auto.offset.store' ] = false ;
550
- } else {
551
- this . #userManagedStores = ! rdKafkaConfig [ 'enable.auto.offset.store' ] ;
534
+ /* We handle offset storage within the promisified API by ourselves. Thus we don't allow the user to change this
535
+ * setting and set it to false. */
536
+ if ( Object . hasOwn ( this . #userConfig, 'enable.auto.offset.store' ) ) {
537
+ throw new error . KafkaJSError (
538
+ "Changing 'enable.auto.offset.store' is unsupported while using the promisified API." ,
539
+ { code : error . ErrorCodes . ERR__INVALID_ARG } ) ;
552
540
}
541
+ rdKafkaConfig [ 'enable.auto.offset.store' ] = false ;
553
542
554
543
if ( ! Object . hasOwn ( rdKafkaConfig , 'enable.auto.commit' ) ) {
555
544
this . #autoCommit = true ; /* librdkafka default. */
@@ -663,13 +652,11 @@ class Consumer {
663
652
payload . _lastResolvedOffset = { offset, leaderEpoch } ;
664
653
665
654
try {
666
- if ( ! this . #userManagedStores) {
667
- this . #internalClient. _offsetsStoreSingle (
668
- topic ,
669
- partition ,
670
- offset + 1 ,
671
- leaderEpoch ) ;
672
- }
655
+ this . #internalClient. _offsetsStoreSingle (
656
+ topic ,
657
+ partition ,
658
+ offset + 1 ,
659
+ leaderEpoch ) ;
673
660
this . #lastConsumedOffsets. set ( key , offset + 1 ) ;
674
661
} catch ( e ) {
675
662
/* Not much we can do, except log the error. */
@@ -1076,9 +1063,7 @@ class Consumer {
1076
1063
/* Store the offsets we need to store, or at least record them for cache invalidation reasons. */
1077
1064
if ( eachMessageProcessed ) {
1078
1065
try {
1079
- if ( ! this . #userManagedStores) {
1080
- this . #internalClient. _offsetsStoreSingle ( m . topic , m . partition , Number ( m . offset ) + 1 , m . leaderEpoch ) ;
1081
- }
1066
+ this . #internalClient. _offsetsStoreSingle ( m . topic , m . partition , Number ( m . offset ) + 1 , m . leaderEpoch ) ;
1082
1067
this . #lastConsumedOffsets. set ( partitionKey ( m ) , Number ( m . offset ) + 1 ) ;
1083
1068
} catch ( e ) {
1084
1069
/* Not much we can do, except log the error. */
@@ -1299,30 +1284,6 @@ class Consumer {
1299
1284
// return m ?? null;
1300
1285
}
1301
1286
1302
- /**
1303
- * Store offsets for the given topic partitions.
1304
- *
1305
- * Stored offsets will be commited automatically at a later point if autoCommit is enabled.
1306
- * Otherwise, they will be committed when commitOffsets is called without arguments.
1307
- *
1308
- * enable.auto.offset.store must be set to false to use this API.
1309
- * @param {import("../../types/kafkajs").TopicPartitionOffset[]? } topicPartitions
1310
- */
1311
- storeOffsets ( topicPartitions ) {
1312
- if ( this . #state !== ConsumerState . CONNECTED ) {
1313
- throw new error . KafkaJSError ( 'Store can only be called while connected.' , { code : error . ErrorCodes . ERR__STATE } ) ;
1314
- }
1315
-
1316
- if ( ! this . #userManagedStores) {
1317
- throw new error . KafkaJSError (
1318
- 'Store can only be called when enable.auto.offset.store is explicitly set to false.' , { code : error . ErrorCodes . ERR__INVALID_ARG } ) ;
1319
- }
1320
-
1321
- const topicPartitionsRdKafka = topicPartitions . map (
1322
- topicPartitionOffsetMetadataToRdKafka ) ;
1323
- this . #internalClient. offsetsStore ( topicPartitionsRdKafka ) ;
1324
- }
1325
-
1326
1287
async #commitOffsetsUntilNoStateErr( offsetsToCommit ) {
1327
1288
let err = { code : error . ErrorCodes . ERR_NO_ERROR } ;
1328
1289
do {
0 commit comments