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

Provide a configuration property for JMS listener container's max messages per task #39533

Closed
apinske opened this issue Feb 13, 2024 · 3 comments
Labels
status: superseded An issue that has been superseded by another type: enhancement A general enhancement

Comments

@apinske
Copy link

apinske commented Feb 13, 2024

  • Spring Boot 2.7.18
  • Default DMLC JMS Listener Config
  • the active listener threads do not automatically scale down (using default config)
  • taken code path org.springframework.jms.listener.DefaultMessageListenerContainer.AsyncMessageListenerInvoker.executeOngoingLoop()
  • there is no default mechanism to change the path taken, i.e. no spring.jms.listener.max-messages-per-task property)
  1. I don't understand the need for the two code paths in spring-framework in the first place
  2. but since they are there, somewhere this problem should be addressed
    1. either fix spring-framework to also scale down in the executeOngoingLoop-Case
    2. in spring-boot use the other code-path (e.g. set maxMessagesPerTask=1); or at least make it configurable through spring-boot

Find a sample here: https://github.com/apinske/playground-mq/tree/scaling

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 13, 2024
@wilkinsona
Copy link
Member

wilkinsona commented Feb 13, 2024

There's no configuration property for maxMessagesPerTask, but you can configure it by defining your own DefaultMessageListenerContainerFactory and using DefaultJmsListenerContainerFactoryConfigurer to apply Boot's defaults:

@Bean
DefaultJmsListenerContainerFactory jmsListenerContainerFactory(
		DefaultJmsListenerContainerFactoryConfigurer configurer, ConnectionFactory connectionFactory) {
	DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
	configurer.configure(factory, connectionFactory);
	factory.setMaxMessagesPerTask(1);
	return factory;
}

We could consider adding a configuration property for this if we feel that it would be generally useful.

Your other points about Spring Framework will have to be addressed by the Framework team. Please open an issue with them for their consideration. We'll keep this issue in Boot's tracker to consider a configuration property for the maximum messages per task.

@wilkinsona wilkinsona changed the title DMLC doesn't scale down in default-config Provide a configuration property for JMS listener container's max messages per task Feb 13, 2024
@apinske
Copy link
Author

apinske commented Feb 13, 2024

Might I offer a suggestion: You could make JmsListenerContainerFactoryConfigurer an interface, and discover all beans, like other places of spring-boot do. Then it would be easier to customise.

@snicoll
Copy link
Member

snicoll commented Sep 18, 2024

Closing in favor of PR #42341

@snicoll snicoll closed this as not planned Won't fix, can't repro, duplicate, stale Sep 18, 2024
@snicoll snicoll removed this from the 3.x milestone Sep 18, 2024
@snicoll snicoll added the status: superseded An issue that has been superseded by another label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants