Skip to content

Commit a0c92f1

Browse files
Assert on x-death event counters
1 parent 854ce3b commit a0c92f1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/src/com/rabbitmq/client/test/server/XDeathHeaderGrowth.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public void handleDelivery(String consumerTag, Envelope envelope,
3232
if(this.latch.getCount() > 0) {
3333
this.getChannel().basicReject(envelope.getDeliveryTag(), false);
3434
} else {
35-
this.getChannel().basicAck(envelope.getDeliveryTag(), false);
35+
if(this.getChannel().isOpen()) {
36+
this.getChannel().basicAck(envelope.getDeliveryTag(), false);
37+
}
3638
}
3739
this.headers = properties.getHeaders();
3840
latch.countDown();
@@ -44,6 +46,7 @@ public Map<String, Object> getHeaders() {
4446
}
4547

4648
public class XDeathHeaderGrowth extends BrokerTestCase {
49+
@SuppressWarnings("unchecked")
4750
public void testBoundedXDeathHeaderGrowth() throws IOException, InterruptedException {
4851
final String x1 = "issues.rabbitmq-server-78.fanout1";
4952
declareTransientFanoutExchange(x1);
@@ -71,7 +74,7 @@ public void testBoundedXDeathHeaderGrowth() throws IOException, InterruptedExcep
7174
declareTransientQueue(qz, args4);
7275
this.channel.queueBind(qz, x3, "");
7376

74-
CountDownLatch latch = new CountDownLatch(5);
77+
CountDownLatch latch = new CountDownLatch(10);
7578
RejectingConsumer cons = new RejectingConsumer(this.channel, latch);
7679
this.channel.basicConsume(qz, cons);
7780

@@ -86,6 +89,12 @@ public void testBoundedXDeathHeaderGrowth() throws IOException, InterruptedExcep
8689
}
8790
Collections.sort(qs);
8891
assertEquals(Arrays.asList(qz, q1, q2, q3), qs);
92+
List<Long> cs = new ArrayList<Long>();
93+
for (Map<String, Object> evt : events) {
94+
cs.add((Long)evt.get("counter"));
95+
}
96+
Collections.sort(cs);
97+
assertEquals(Arrays.asList(1L, 1L, 1L, 9L), cs);
8998
}
9099

91100
private Map<String, Object> argumentsForDeadLetteringTo(String dlx) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy