-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Add support for auto-configuring SimpleMessageListenerContainer #44465
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
Conversation
Thanks for the suggestion but we don't really consider a promotion of What's your use of |
Semantics of
My specific use case is that I'm using SQS and Amazon SQS Java Messaging Library provided by AWS. This JMS implementation doesn't support transactions, but provides custom acknowledge mode that better fits SQS, and internally has its own prefetching/polling mechanism that aligns usage of SQS API with JMS spec. From my experience I'd like to avoid copying boilerplate configuration from project to project and use configuration property based approach to opt into using |
5ced34f
to
c71222e
Compare
...org/springframework/boot/autoconfigure/jms/DefaultJmsListenerContainerFactoryConfigurer.java
Outdated
Show resolved
Hide resolved
This commit introduces a new `spring.jms.listener.container-type` configuration property which can be used to auto-configure JMS listener support backend by `SimpleMessageListenerContainer` instead of `DefaultMessageListenerContainer`. Signed-off-by: Vedran Pavic <vedran@vedranpavic.com>
c71222e
to
2c4eedc
Compare
No, it doesn't sound like that. If it was, the class would be deprecated. I wrote "invest", which means we haven't been touching the simple implementation and recommend folks to use the pooling approach. I think we can move forward but I would make the following changes to make the PR actionable:
We can reconsider based on the above, thanks! |
@vpavic can you please review the above and let us know if you want to amend your PR accordingly? |
Closing due to the lack of feedback. |
Sorry for the late follow-up, I've been struggling to find time for open-source activities in the recent weeks. In my previous comment I've already linked to Message Listener Containers section of the Spring Framework reference docs that describes both message listener container implementations quite well, and coupled with documentation present in javadoc of both From there, it's clear that the two have quite different semantics - push-based in My point is, from Spring Framework perspective both message listener container implementations are equally represented in the documentation that very clearly describes pros and cons of each. On the other hand, Spring Boot's auto-configuration just sets up To address the specific requests:
I'm not sure what exactly you had in mind, but I've already mentioned the wealth of documentation on Framework side - shouldn't Spring Boot's reference documentation somewhere just link to that? I can try to add a sentence or two that do that.
Without that property, what's the benefit? I'm currently doing this in my project: @Bean
SimpleJmsListenerContainerFactory jmsListenerContainerFactory(ConnectionFactory connectionFactory,
BeanFactoryDestinationResolver destinationResolver) {
SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactory);
factory.setDestinationResolver(destinationResolver);
factory.setSessionAcknowledgeMode(SQSSession.UNORDERED_ACKNOWLEDGE);
return factory;
} Since this is a very frequent piece of boilerplate configuration that I would need to copy from project to project I was hoping to reduce that to: spring.jms.listener.container-type=simple
spring.jms.listener.session.acknowledge-mode=100 Seems like a reasonable expectation to me. If I would need to declare
This I agree isn't ideal but isn't too bad IMO, as this pattern exists in some other auto-configurations and such properties already contain Applies only to container type Could you please reconsider this PR based on the feedback provided here? I see that it was labeled |
That's an interpretation on your end I am afraid. The choice will cause confusion. Just because you're versed in the topic doesn't mean that the average user is. And, from experience, I've seen quite a bit of people using Spring Framework not knowing what to chose. Not providing auto-configuration for the Simple implementation is not oversight but a conscious decision. Also you're the first person asking for this.
This is a technical doc and one should put the pieces together to form an opinion. What you wrote in your comment would be a very good start in our reference doc, I think.
Two things. One, we don't want to confuse users with the option. By your own admission, you use case is quite specific and you'd like better support for it. That's fine, it doesn't mean though that it should lead to more configuration properties. Second, this PR shows that a number of properties are not applicable to the simple implementation. This is problematic and, for a non-mainstream use case, doesn't warrant the switch. The benefit is that you can inject the builder and easily configure the connection factory you want.
I wish you gave me more credit. Phil was wondering about the differences between the two and we obviously discussed this before I closed it. |
I cannot agree on the confusion part you keep insisting on. Does Framework inflict confusion by offering both These days many developers learn about Framework's features through Spring Boot - I've witnessed this so many times and there are Framework features many are unaware because those aren't surfaced in Spring Boot. I agree that not every feature needs to be a first-class citizen, but here specifically we're talking about two semantically different but well established and documented features that receive equal treatment in the Framework (FWIW simple implementation is even listed first there). I don't believe my use case is that specific, there are many providers and/or workloads where |
That is fine. I've witnessed the confusion time and time again but you don't have to trust me, I guess.
I don't see the argument of providing some "type" property that we already provide. None of those match the conversation that we're having here. All in all, I think this conversation has reached its course. If you want to amend your PR as I've suggested above, then please do so and I'll be happy to review it. Perhaps some more refinement will occur based on the code. And it is a first good step in what you're trying to achieve and that doesn't prevent us to keep refining it based on the community's feedback. |
This commit introduces a new
spring.jms.listener.container-type
configuration property which can be used to auto-configure JMS listener support backend bySimpleMessageListenerContainer
instead ofDefaultMessageListenerContainer
.