Skip to content

Commit cdf36cd

Browse files
committed
Fix race condition in the MessageListenerContainerMultipleQueueIntegrationTests
1 parent b76b619 commit cdf36cd

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

spring-rabbit/src/test/java/org/springframework/amqp/rabbit/listener/MessageListenerContainerMultipleQueueIntegrationTests.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package org.springframework.amqp.rabbit.listener;
1818

19-
import static org.assertj.core.api.Assertions.assertThat;
20-
2119
import java.util.concurrent.CountDownLatch;
2220
import java.util.concurrent.TimeUnit;
2321
import java.util.concurrent.atomic.AtomicInteger;
@@ -36,15 +34,18 @@
3634
import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter;
3735
import org.springframework.amqp.support.converter.SimpleMessageConverter;
3836

37+
import static org.assertj.core.api.Assertions.assertThat;
38+
3939
/**
4040
* @author Mark Fisher
4141
* @author Gunnar Hillert
4242
* @author Gary Russell
43+
* @author Artem Bilan
4344
*/
44-
@RabbitAvailable(queues = { MessageListenerContainerMultipleQueueIntegrationTests.TEST_QUEUE_1,
45-
MessageListenerContainerMultipleQueueIntegrationTests.TEST_QUEUE_2 })
46-
@LogLevels(level = "INFO", classes = { RabbitTemplate.class,
47-
SimpleMessageListenerContainer.class, BlockingQueueConsumer.class })
45+
@RabbitAvailable(queues = {MessageListenerContainerMultipleQueueIntegrationTests.TEST_QUEUE_1,
46+
MessageListenerContainerMultipleQueueIntegrationTests.TEST_QUEUE_2})
47+
@LogLevels(level = "INFO", classes = {RabbitTemplate.class,
48+
SimpleMessageListenerContainer.class, BlockingQueueConsumer.class})
4849
public class MessageListenerContainerMultipleQueueIntegrationTests {
4950

5051
public static final String TEST_QUEUE_1 = "test.queue.1.MessageListenerContainerMultipleQueueIntegrationTests";
@@ -77,7 +78,6 @@ public void testMultipleQueueNamesWithConcurrentConsumers() {
7778
doTest(3, container -> container.setQueueNames(queue1.getName(), queue2.getName()));
7879
}
7980

80-
8181
private void doTest(int concurrentConsumers, ContainerConfigurer configurer) {
8282
int messageCount = 10;
8383
RabbitTemplate template = new RabbitTemplate();
@@ -119,17 +119,15 @@ private void doTest(int concurrentConsumers, ContainerConfigurer configurer) {
119119
container.shutdown();
120120
assertThat(container.getActiveConsumerCount()).isEqualTo(0);
121121
}
122-
assertThat(template.receiveAndConvert(queue1.getName())).isNull();
123-
assertThat(template.receiveAndConvert(queue2.getName())).isNull();
124-
125122
connectionFactory.destroy();
126123
}
127124

128125
@FunctionalInterface
129126
private interface ContainerConfigurer {
127+
130128
void configure(SimpleMessageListenerContainer container);
131-
}
132129

130+
}
133131

134132
@SuppressWarnings("unused")
135133
private static class PojoListener {
@@ -150,6 +148,7 @@ public void handleMessage(int value) throws Exception {
150148
public int getCount() {
151149
return count.get();
152150
}
151+
153152
}
154153

155154
}

0 commit comments

Comments
 (0)