-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
Maxim Popov opened SPR-16536 and commented
[configuration]
The problem is reproduced whem JMS prefetch size is set to 0.
connectionFactory.getPrefetchPolicy().setQueuePrefetch(0);
[description]
@DirtiesContext
(classMode=DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD) annotations triggers org.springframework.context.support.DefaultLifecycleProcessor.LifecycleGroup.stop() method which tries to shutdown bean org.springframework.jms.config.JmsListenerEndpointRegistry.
When JmsListenerEndpointRegistry stops, it calls stop on DefaultMessageListenerContainer which is marked stopped by flag 'running'
this.running = false;
But ActiveMQMessageConsumer is blocked by waiting a message from broker when prefetch size is 0
if (info.getPrefetchSize() == 0) {
md = dequeue(-1); // We let the broker let us know when we timeout.
} else {
md = dequeue(timeout);
}
So DefaultMessageListenerContainer can't react on flag 'running' and continue to wait a message.
As result DefaultLifecycleProcessor.LifecycleGroup.stop() is waiting 30 seconds to stop normally without any success.
latch.await(this.timeout, TimeUnit.MILLISECONDS);
Affects: 4.3.14
Issue Links:
- Application Server Fail to Stop Application and server while stopping transactions with spring [SPR-16586] #21128 Application Server Fail to Stop Application and server while stopping transactions with spring
- ThreadPoolTaskExecutor should cancel all remaining Future handles on shutdown [SPR-16607] #21148 ThreadPoolTaskExecutor should cancel all remaining Future handles on shutdown