|
26 | 26 | import static com.rabbitmq.client.amqp.impl.TestConditions.BrokerVersion.RABBITMQ_4_1_0; |
27 | 27 | import static com.rabbitmq.client.amqp.impl.TestConditions.BrokerVersion.RABBITMQ_4_2_0; |
28 | 28 | import static com.rabbitmq.client.amqp.impl.TestUtils.sync; |
| 29 | +import static com.rabbitmq.client.amqp.impl.TestUtils.waitAtMost; |
29 | 30 | import static com.rabbitmq.client.amqp.impl.TestUtils.waitUntilStable; |
30 | 31 | import static java.nio.charset.StandardCharsets.UTF_8; |
31 | 32 | import static java.util.stream.IntStream.range; |
@@ -590,13 +591,15 @@ void publish(int messageCount, String filterValue) { |
590 | 591 | void publish(int messageCount, UnaryOperator<Message> messageLogic) { |
591 | 592 | try (Publisher publisher = connection.publisherBuilder().queue(name).build()) { |
592 | 593 | Sync publishSync = sync(messageCount); |
593 | | - Publisher.Callback callback = ctx -> { |
594 | | - if (ctx.status() == ACCEPTED) { |
595 | | - publishSync.down(); |
596 | | - } else { |
597 | | - LOGGER.warn("Outbound message not accepted by the broker, status is {}", ctx.status()); |
598 | | - } |
599 | | - }; |
| 594 | + Publisher.Callback callback = |
| 595 | + ctx -> { |
| 596 | + if (ctx.status() == ACCEPTED) { |
| 597 | + publishSync.down(); |
| 598 | + } else { |
| 599 | + LOGGER.warn( |
| 600 | + "Outbound message not accepted by the broker, status is {}", ctx.status()); |
| 601 | + } |
| 602 | + }; |
600 | 603 | range(0, messageCount) |
601 | 604 | .forEach(ignored -> publisher.publish(messageLogic.apply(publisher.message()), callback)); |
602 | 605 | assertThat(publishSync).completes(); |
@@ -625,7 +628,7 @@ List<Message> consume( |
625 | 628 |
|
626 | 629 | try (Consumer ignored = builder.build()) { |
627 | 630 | assertThat(consumedSync).completes(); |
628 | | - waitUntilStable(receivedMessageCount::get, Duration.ofMillis(50)); |
| 631 | + waitAtMost(() -> receivedMessageCount.get() >= expectedMessageCount); |
629 | 632 | assertThat(receivedMessageCount).hasValue(expectedMessageCount); |
630 | 633 | } |
631 | 634 |
|
|
0 commit comments