Skip to content

Add JmsTemplate overloads to JMS DSL channel specs#10933

Open
cppwfs wants to merge 2 commits intospring-projects:mainfrom
cppwfs:SI-2679
Open

Add JmsTemplate overloads to JMS DSL channel specs#10933
cppwfs wants to merge 2 commits intospring-projects:mainfrom
cppwfs:SI-2679

Conversation

@cppwfs
Copy link
Copy Markdown
Contributor

@cppwfs cppwfs commented Apr 10, 2026

Fixes: #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

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`
@cppwfs cppwfs requested a review from artembilan April 10, 2026 17:35
Copy link
Copy Markdown
Member

@artembilan artembilan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some mentioning of this new option in the whats-new.adoc would be great.

Thanks

}

/**
* The template to produce a {@link JmsPollableMessageChannelSpec}.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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("");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants