@@ -24,7 +24,7 @@ def _create_consumer_kafka_python(bootstrap: str, base_cfg: Dict[str, Any]):
2424 "enable_auto_commit" : False ,
2525 "auto_offset_reset" : "earliest" ,
2626 }
27- copy_client_configuration_properties (base_cfg , consumer_cfg )
27+ copy_client_configuration_properties (base_cfg , consumer_cfg , "kafka-python" )
2828 return kafka .KafkaConsumer (** consumer_cfg )
2929
3030def _create_consumer_aiokafka (bootstrap : str , base_cfg : Dict [str , Any ]):
@@ -36,7 +36,7 @@ def _create_consumer_aiokafka(bootstrap: str, base_cfg: Dict[str, Any]):
3636 "enable_auto_commit" : False ,
3737 "auto_offset_reset" : "earliest" ,
3838 }
39- copy_client_configuration_properties (base_cfg , consumer_cfg )
39+ copy_client_configuration_properties (base_cfg , consumer_cfg , "aiokafka" )
4040 return AIOKafkaConsumer (** consumer_cfg )
4141
4242def _create_consumer_confluent (bootstrap : str , base_cfg : Dict [str , Any ]):
@@ -48,7 +48,7 @@ def _create_consumer_confluent(bootstrap: str, base_cfg: Dict[str, Any]):
4848 "enable.auto.commit" : False ,
4949 "auto.offset.reset" : "earliest" ,
5050 }
51- copy_client_configuration_properties (base_cfg , consumer_cfg )
51+ copy_client_configuration_properties (base_cfg , consumer_cfg , "confluent" )
5252 return Consumer (consumer_cfg )
5353
5454_CONSUMER_BUILDERS = {
@@ -108,14 +108,18 @@ def fetch_metadata(
108108
109109 tp = _kafka .TopicPartition (topic , 0 )
110110 consumer .assign ([tp ])
111- consumer .seek_to_end (tp )
112- end = consumer .position (tp )
111+
112+ # Get the end offset safely
113+ end_offsets = consumer .end_offsets ([tp ])
114+ end = end_offsets .get (tp , 0 )
115+
113116 if end == 0 :
114117 logger .error (
115118 "[ERR-202] Unable to retrieve optimizations data from Superstream – topic empty."
116119 )
117120 consumer .close ()
118121 return None
122+
119123 consumer .seek (tp , end - 1 )
120124 recs = consumer .poll (timeout_ms = 5000 )
121125 consumer .close ()
0 commit comments