Use batch index acknowledgement with Starlight for JMS
Starlight for JMS improves acknowledgement of batched messages by supporting the tracking of 'ack' status by batch index.
By default, filtering works on the entry level in Pulsar. An entry is a single message, or a single batch of messages. The client cannot selectively filter messages in a batch; it either passes completely or fails completely.
With batch index acknowledgement, when the broker dispatches messages, it carries the batch index that has been acknowledged. Then, the client filters out batch indexes that have been acknowledged. Finally, the client sends the batch index acknowledgement information to the broker so the broker can maintain the batch index acknowledgement status.
|
DataStax strongly recommends using batch index acknowledgement for increased efficiency, whether using broker-side or client-side selectors. |
Enable batch index acknowledgement
Batch index acknowledgement requires cooperation between the client and broker.
You must modify both broker.conf and the consumerConfig JMS client property to enable batch acknowledgement:
-
In your
broker.conffile, add the configuration propertyacknowledgmentAtBatchIndexLevelEnabledand set it totrue:acknowledgmentAtBatchIndexLevelEnabled=true -
In your Java project, set the
consumerConfigproperty on the JMS client by addingconsumerConfig.put("batchIndexAckEnabled", true);toconsumerConfigin theConnectionFactoryconfiguration:Map<String, Object> properties = new HashMap<>(); properties.put("webServiceUrl", cluster.getAddress()); Map<String, Object> consumerConfig = new HashMap<>(); consumerConfig.put("batchIndexAckEnabled", true); properties.put("consumerConfig", consumerConfig); try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties));