Skip to content

DefaultMessageListenerContainer should interrupt worker threads when not returning on shutdown [SPR-16536] #21079

@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits c6bd0c9, 59f1263, 95aad9c

Metadata

Metadata

Assignees

Labels

in: messagingIssues in messaging modules (jms, messaging)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions