Skip to content

Add JmsTemplate overloads to JMS DSL channel specs#10933

Open
cppwfs wants to merge 1 commit intospring-projects:mainfrom
cppwfs:SI-2679
Open

Add JmsTemplate overloads to JMS DSL channel specs#10933
cppwfs wants to merge 1 commit 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

this.jmsTemplate.setSessionAcknowledgeMode(sessionAcknowledgeMode);
}

public void setJmsTemplate(JmsTemplate 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.

@since and some other Javadocs.

And now, having this externally injected we need to protect against mutation.
Pay attention to all those setters delegating to the this.jmsTemplate.
We need to reject with something like assertLocalClient() in the HttpRequestExecutingMessageHandler.
The change is not one-to-one since here we don't have ctor injection, so might be the case that validation should go to the createInstance() (or initializeJmsTemplate()) when we would not worry about an order all those setters are called.

}

/**
* 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.

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