- 
                Notifications
    
You must be signed in to change notification settings  - Fork 38.8k
 
Closed
Labels
in: messagingIssues in messaging modules (jms, messaging)Issues in messaging modules (jms, messaging)type: enhancementA general enhancementA general enhancement
Milestone
Description
Oleg Ivanov opened SPR-14200 and commented
Currently in DefaultMessageListenerContainer.applyBackOffTime(BackOffExecution execution) function the current thread is sleeping during the back off interval. This prevents container to shutdown correctly (as it waits for this thread to wake up).
I suggest to rewrite this function using .wait() calls:
        final long interval = execution.nextBackOff();
        if (interval == BackOffExecution.STOP)
            return false;
        if (isRecovering() && interrupted)
            // Interrupted right before and still failing... give up.
            return false;
        try {
            synchronized (this.lifecycleMonitor) {
                final long start = System.currentTimeMillis();
                while (isActive() && System.currentTimeMillis() - start < interval) {
                    final long timeout = getReceiveTimeout();
                    this.lifecycleMonitor.wait(timeout > 0 ? timeout : DEFAULT_RECEIVE_TIMEOUT);
                }
            }
        } catch (InterruptedException interEx) {
            // Re-interrupt current thread, to allow other threads to react.
            Thread.currentThread().interrupt();
            if (isRecovering())
                this.interrupted = true;
        }
        return true;Affects: 4.2.5
Issue Links:
- DefaultMessageListenerContainer hangs on shutdown [SPR-11787] #16409 DefaultMessageListenerContainer hangs on shutdown
 - DefaultMessageListenerContainer#doShutdown hangs [SPR-11841] #16460 DefaultMessageListenerContainer#doShutdown hangs
 - Client-side polling delay as alternative for receive timeout for JMS [SPR-14225] #18799 Client-side polling delay as alternative for receive timeout for JMS
 
Referenced from: commits 6ab8d36
Metadata
Metadata
Assignees
Labels
in: messagingIssues in messaging modules (jms, messaging)Issues in messaging modules (jms, messaging)type: enhancementA general enhancementA general enhancement