Add JmsTemplate overloads to JMS DSL channel specs#10933
Add JmsTemplate overloads to JMS DSL channel specs#10933cppwfs wants to merge 2 commits intospring-projects:mainfrom
Conversation
Fixes: spring-projects#2679 - Allow `JmsChannelFactoryBean` to accept an externally provided `JmsTemplate` - Add `Jms.pollableChannel(JmsTemplate)` and `Jms.pollableChannel(String, JmsTemplate)` factory methods - Add `Jms.channel(JmsTemplate)` factory method - Add protected constructors to `JmsPollableMessageChannelSpec` and `JmsMessageChannelSpec` accepting `JmsTemplate` - Add integration test verifying the polling flow with a `JmsTemplate`
artembilan
left a comment
There was a problem hiding this comment.
Some mentioning of this new option in the whats-new.adoc would be great.
Thanks
| } | ||
|
|
||
| /** | ||
| * The template to produce a {@link JmsPollableMessageChannelSpec}. |
There was a problem hiding this comment.
Maybe factory?
I'm not that "template" is producing anything.
It might be used from something what is producing, like factory 😄
Anyway, this is more about a proper wording in the Javadoc like we have in other methods of this class.
| this.jmsChannelFactoryBean = jmsChannelFactoryBean; | ||
| this.jmsChannelFactoryBean.setJmsTemplate(jmsTemplate); | ||
| this.jmsChannelFactoryBean.setSingleton(false); | ||
| this.jmsChannelFactoryBean.setBeanFactory(new DefaultListableBeanFactory()); |
There was a problem hiding this comment.
Let's consider to move two last lines into the doGet() before getObject().
This way we might not have duplication in these two ctors.
Add a validation guard to `JmsChannelFactoryBean` that prevents users from mixing an externally provided `JmsTemplate` with individual template configuration options set on the factory bean itself. Update the What's New documentation to describe the new `JmsTemplate` support in the JMS DSL.
| String quoted = this.templateDelegatingOptions.stream() | ||
| .map(opt -> "'" + opt + "'") | ||
| .reduce((a, b) -> a + ", " + b) | ||
| .orElse(""); |
There was a problem hiding this comment.
This is interesting, but I think we don't need to track options being set.
Let's just say straight in this error message what options must be set on the template instead if this factory bean!
I mean if at least one of those properties is sent, we set respective boolean flag and check it here.
Then if both for those are true we raise an exception.
|
|
||
| JMS DSL now allows the user to set the `JmsTemplate`. | ||
| When using an external `JmsTemplate` it must be configured prior to when it is set, because the DSL can only set the | ||
| configurations for the default `JMSTemplate`. |
There was a problem hiding this comment.
First of all typo in the JmsTemplate word.
And second: one sentence per line: https://asciidoctor.org/docs/asciidoc-recommended-practices/.
If if it is too long, it is still has to be on one line.
The 120 is just recommendation for code.
And I believe it might even not apply for XML or Gradle.
Just Java, Kotlin, Groovy source code.
Fixes: #2679
JmsChannelFactoryBeanto accept an externally providedJmsTemplateJms.pollableChannel(JmsTemplate)andJms.pollableChannel(String, JmsTemplate)factory methodsJms.channel(JmsTemplate)factory methodJmsPollableMessageChannelSpecandJmsMessageChannelSpecacceptingJmsTemplateJmsTemplate