@@ -98,18 +98,18 @@ private void testChangeConsumerCountGuts(boolean transacted) throws Exception {
98
98
container .setMaxConcurrentConsumers (3 );
99
99
RabbitTemplate template = new RabbitTemplate (singleConnectionFactory );
100
100
for (int i = 0 ; i < 20 ; i ++) {
101
- template .convertAndSend ("foo" , "foo" );
101
+ template .convertAndSend (QUEUE , "foo" );
102
102
}
103
103
waitForNConsumers (container , 2 ); // increased consumers due to work
104
104
waitForNConsumers (container , 1 , 20000 ); // should stop the extra consumer after 10 seconds idle
105
105
container .setConcurrentConsumers (3 );
106
106
waitForNConsumers (container , 3 );
107
107
container .stop ();
108
108
waitForNConsumers (container , 0 );
109
- singleConnectionFactory .destroy ();
110
109
}
111
110
finally {
112
111
container .stop ();
112
+ singleConnectionFactory .destroy ();
113
113
}
114
114
}
115
115
@@ -141,14 +141,15 @@ public void testAddQueuesAndStartInCycle() throws Exception {
141
141
for (int i = 0 ; i < 20 ; i ++) {
142
142
admin .deleteQueue ("testAddQueuesAndStartInCycle" + i );
143
143
}
144
+
144
145
connectionFactory .destroy ();
145
146
}
146
147
147
148
@ Test
148
149
public void testIncreaseMinAtMax () throws Exception {
149
150
final SingleConnectionFactory singleConnectionFactory = new SingleConnectionFactory ("localhost" );
150
151
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer (singleConnectionFactory );
151
- container .setStartConsumerMinInterval (100 );
152
+ container .setStartConsumerMinInterval (1 );
152
153
container .setConsecutiveActiveTrigger (1 );
153
154
container .setMessageListener ((MessageListener ) m -> {
154
155
try {
@@ -171,6 +172,9 @@ public void testIncreaseMinAtMax() throws Exception {
171
172
container .setConcurrentConsumers (4 );
172
173
Set <?> consumers = (Set <?>) TestUtils .getPropertyValue (container , "consumers" );
173
174
assertThat (consumers .size (), equalTo (5 ));
175
+
176
+ container .stop ();
177
+ singleConnectionFactory .destroy ();
174
178
}
175
179
176
180
@ Test
@@ -200,6 +204,9 @@ public void testDecreaseMinAtMax() throws Exception {
200
204
container .setConcurrentConsumers (1 );
201
205
Set <?> consumers = (Set <?>) TestUtils .getPropertyValue (container , "consumers" );
202
206
assertThat (consumers .size (), equalTo (3 ));
207
+
208
+ container .stop ();
209
+ singleConnectionFactory .destroy ();
203
210
}
204
211
205
212
@ Test
@@ -230,6 +237,9 @@ public void testDecreaseMaxAtMax() throws Exception {
230
237
container .setMaxConcurrentConsumers (1 );
231
238
Set <?> consumers = (Set <?>) TestUtils .getPropertyValue (container , "consumers" );
232
239
assertThat (consumers .size (), equalTo (1 ));
240
+
241
+ container .stop ();
242
+ singleConnectionFactory .destroy ();
233
243
}
234
244
235
245
public void handleMessage (String foo ) {
@@ -240,7 +250,9 @@ private void waitForNConsumers(SimpleMessageListenerContainer container, int n)
240
250
this .waitForNConsumers (container , n , 10000 );
241
251
}
242
252
243
- private void waitForNConsumers (SimpleMessageListenerContainer container , int n , int howLong ) throws InterruptedException {
253
+ private void waitForNConsumers (SimpleMessageListenerContainer container , int n , int howLong )
254
+ throws InterruptedException {
255
+
244
256
int i = 0 ;
245
257
while (true ) {
246
258
Set <?> consumers = (Set <?>) TestUtils .getPropertyValue (container , "consumers" );
0 commit comments