Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultLifecycleProcessor hangs on shutdown when stopping with internalJmsListenerEndpointRegistry [SPR-14233] #18807

Closed
spring-issuemaster opened this issue Apr 29, 2016 · 10 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Apr 29, 2016

Dirk opened SPR-14233 and commented

We are having the following configuration:

  • 2 JMSListener
  • XA Transactions with Atomikos or Bitronix
  • Spring Boot 1.3.3

The application runs fine but after shutdown, the DefaultLifecycleProcessor is waiting 30 seconds and then prints:

43621 [Thread-7] WARN  org.springframework.context.support.DefaultLifecycleProcessor  - Failed to shut down 1 bean with phase value 2147483647 within timeout of 30000: [org.springframework.jms.config.internalJmsListenerEndpointRegistry]

This happens only, if one of the JMSListener gets stopped before by doing:

JmsListenerEndpointRegistry registry = context.getBean(JmsListenerEndpointRegistry.class);
registry.getListenerContainer("MyListener1").stop();

If I comment one listener out, or keep both JMSListener running - the timeout does not happen and the application shuts down immediately.

The app hangs even if no work has been processed. I reduced the JMSListener
to contain no own business logic at all:

public class MyListener {

	// Die ID wird benoetigt, damit der Listener programmatisch gestoppt werden kann
	protected static final String ID = "MyListener1";

	@JmsListener(id = ID, destination="MYQUEUE")
	public void receiveMessage(Message msg) {
		System.out.println("Hello!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
	}
}

The problem arises both with Atomikos and Bitronix.

So to me, it looks like you need to have 2 JMSListeners and need to stop one of them to reproduce this problem.

Any help would be appreciated.


Affects: 4.2.5

Referenced from: commits 85675fb, 85faeef, 09b45d2, e45d33f, f83cbff

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 2, 2016

Stéphane Nicoll commented

Thanks for the report, I was able to reproduce the issue. Investigating...

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 2, 2016

Dirk commented

Great - first step to find a solution ;-)

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 2, 2016

Stéphane Nicoll commented

Alright, the issue is fixed on master. Juergen Hoeller can you please backport that to 4.2.x?

It turns out that DefaultMessageListenerContainer was not honouring the stop callback in a particular scenario that was revealed by your use case. Could you please try again in a couple of hours once 4.3.0.BUILD-SNAPSHOT is available? Or you could wait for the backport and test with 4.2.6.BUILD-SNAPSHOT. We're releasing these this week so a confirmation would be much appreciated.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 2, 2016

Dirk commented

Wow - that was really fast! Thanks! I will test it on 4.2.6.BUILD-SNAPSHOT. I will let you know if that's working now for us!

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 2, 2016

Juergen Hoeller commented

A 4.2.6.BUILD-SNAPSHOT including this fix will be available in about half an hour.... Indeed, please give it a try once available!

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 2, 2016

Dirk commented

I would expect that this not completely fixes my issues, since the hang-up happens even if I restart the MessageListenerContainer again. But I will give it a try ;-) .

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 3, 2016

Dirk commented

Am I looking in the wrong place, or is the build still from yesterday 13:20 o'clock?

http://repo.spring.io/snapshot/org/springframework/spring-core/4.3.0.BUILD-SNAPSHOT/spring-core-4.3.0.BUILD-20160502.132016-367.jar
and
http://repo.spring.io/snapshot/org/springframework/spring-core/4.2.6.BUILD-SNAPSHOT/spring-core-4.2.6.BUILD-20160502.132143-47.jar

But comparing the time, that could nevertheless contain your changes, does it?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 3, 2016

Stéphane Nicoll commented

Both builds have completed successfully within 24h so they will contain the fix. Have you tried and it didn't work so you're asking if the fix is in? That's quite confusing...

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 3, 2016

Dirk commented

Sorry for the confusion and yes, I tried this version already yesterday and still had problems.
But it must have been my fault - today the error messages are completely vanished. I can stop/start MessageListenerContainer like a charme and stopping
the Spring-Boot Application does not lead to hangs anymore.

Thanks for this quick fix and your great work! I know why we are planning to switch from JEE/Appservers to Spring/Spring-Boot wherever possible ;-)

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented May 3, 2016

Stéphane Nicoll commented

Alright, that's great to hear. Thanks for testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.