This is an automated email from the ASF dual-hosted git repository. lhotari pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit e729c90d8b0a50b03945371ed509fdfa8dc89081 Author: Wenzhi Feng <[email protected]> AuthorDate: Fri Feb 14 19:18:06 2025 +0800 [fix][test] fix flaky testNegativeAcksWithBackoff when batch enabled. (#23986) (cherry picked from commit eb7a4f36da3711b9b93527d0bfe26acad1d64b1d) --- .../java/org/apache/pulsar/client/impl/NegativeAcksTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/NegativeAcksTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/NegativeAcksTest.java index 9e8dad44e80..c5aa81e7083 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/NegativeAcksTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/NegativeAcksTest.java @@ -256,9 +256,16 @@ public class NegativeAcksTest extends ProducerConsumerBase { long firstReceivedAt = System.currentTimeMillis(); long expectedTotalRedeliveryDelay = 0; for (int i = 0; i < redeliverCount; i++) { + Message<String> msg = null; for (int j = 0; j < N; j++) { - Message<String> msg = consumer.receive(); + msg = consumer.receive(); log.info("Received message {}", msg.getValue()); + if (!batching) { + consumer.negativeAcknowledge(msg); + } + } + if (batching) { + // for batching, we only need to nack one message in the batch to trigger redelivery consumer.negativeAcknowledge(msg); } expectedTotalRedeliveryDelay += backoff.next(i);
