@@ -692,7 +692,8 @@ def subscribe(self, topic, subscription_name,
692692 auto_ack_oldest_chunked_message_on_queue_full = False ,
693693 start_message_id_inclusive = False ,
694694 batch_receive_policy = None ,
695- key_shared_policy = None
695+ key_shared_policy = None ,
696+ batch_index_ack_enabled = False ,
696697 ):
697698 """
698699 Subscribe to the given topic and subscription combination.
@@ -779,6 +780,9 @@ def my_listener(consumer, message):
779780 Set the batch collection policy for batch receiving.
780781 key_shared_policy: class ConsumerKeySharedPolicy
781782 Set the key shared policy for use when the ConsumerType is KeyShared.
783+ batch_index_ack_enabled: Enable the batch index acknowledgement.
784+ It should be noted that this option can only work when the broker side also enables the batch index
785+ acknowledgement. See the `acknowledgmentAtBatchIndexLevelEnabled` config in `broker.conf`.
782786 """
783787 _check_type (str , subscription_name , 'subscription_name' )
784788 _check_type (ConsumerType , consumer_type , 'consumer_type' )
@@ -800,6 +804,7 @@ def my_listener(consumer, message):
800804 _check_type (bool , start_message_id_inclusive , 'start_message_id_inclusive' )
801805 _check_type_or_none (ConsumerBatchReceivePolicy , batch_receive_policy , 'batch_receive_policy' )
802806 _check_type_or_none (ConsumerKeySharedPolicy , key_shared_policy , 'key_shared_policy' )
807+ _check_type (bool , batch_index_ack_enabled , 'batch_index_ack_enabled' )
803808
804809 conf = _pulsar .ConsumerConfiguration ()
805810 conf .consumer_type (consumer_type )
@@ -834,6 +839,7 @@ def my_listener(consumer, message):
834839
835840 if key_shared_policy :
836841 conf .key_shared_policy (key_shared_policy .policy ())
842+ conf .batch_index_ack_enabled (batch_index_ack_enabled )
837843
838844 c = Consumer ()
839845 if isinstance (topic , str ):
0 commit comments