@Override protected CompletableFuture<Void> doAcknowledge(MessageId messageId, AckType ackType, Map<String,Long> properties) { checkArgument(messageId instanceof MessageIdImpl); if (getState() != State.Ready && getState() != State.Connecting) { stats.incrementNumAcksFailed(); PulsarClientException exception = new PulsarClientException("Consumer not ready. State: " + getState()); if (AckType.Individual.equals(ackType)) { onAcknowledge(messageId, exception); } else if (AckType.Cumulative.equals(ackType)) { onAcknowledgeCumulative(messageId, exception); } return FutureUtil.failedFuture(exception); } if (messageId instanceof BatchMessageIdImpl) { if (markAckForBatchMessage((BatchMessageIdImpl) messageId, ackType, properties)) { // all messages in batch have been acked so broker can be acked via sendAcknowledge() if (log.isDebugEnabled()) { log.debug("[{}] [{}] acknowledging message - {}, acktype {}", subscription, consumerName, messageId, ackType); } } else { // other messages in batch are still pending ack. return CompletableFuture.completedFuture(null); } } return sendAcknowledge(messageId, ackType, properties); }
@Override protected CompletableFuture<Void> doAcknowledge(MessageId messageId, AckType ackType, Map<String,Long> properties) { checkArgument(messageId instanceof MessageIdImpl); if (getState() != State.Ready && getState() != State.Connecting) { stats.incrementNumAcksFailed(); PulsarClientException exception = new PulsarClientException("Consumer not ready. State: " + getState()); if (AckType.Individual.equals(ackType)) { onAcknowledge(messageId, exception); } else if (AckType.Cumulative.equals(ackType)) { onAcknowledgeCumulative(messageId, exception); } return FutureUtil.failedFuture(exception); } if (messageId instanceof BatchMessageIdImpl) { if (markAckForBatchMessage((BatchMessageIdImpl) messageId, ackType, properties)) { // all messages in batch have been acked so broker can be acked via sendAcknowledge() if (log.isDebugEnabled()) { log.debug("[{}] [{}] acknowledging message - {}, acktype {}", subscription, consumerName, messageId, ackType); } } else { // other messages in batch are still pending ack. return CompletableFuture.completedFuture(null); } } return sendAcknowledge(messageId, ackType, properties); }