Skip to content

Unable to configure error message strategy for JMS channel adapters and gateways #10046

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

Closed
matthera opened this issue May 20, 2025 · 5 comments
Closed

Comments

@matthera
Copy link

In what version(s) of Spring Integration are you seeing this issue?

2.0.4.RELEASE -> LATEST (currently 6.5.0-RC1)

Describe the bug

The ChannelPublishingJmsMessageListener fails to proxy the setErrorMessageStrategy/getErrorMessageStrategy methods on its internal GatewayDelegate. This makes setting the error message strategy for message driven JMS channel adapters and gateways impossible.

To Reproduce

  1. Call the 'setErrorMessageStrategy' method on ChannelPublishingJmsMessageListener.
  2. Notice the code compilation error.

Expected behavior

The ChannelPublishingJmsMessageListener should proxy the setErrorMessageStrategy/getErrorMessageStrategy methods on its internal GatewayDelegate.

Sample

n/a

@matthera matthera added type: bug status: waiting-for-triage The issue need to be evaluated and its future decided labels May 20, 2025
@mjd507
Copy link
Contributor

mjd507 commented May 20, 2025

    @Bean
    public IntegrationFlow jmsMessageDrivenFlow(ConnectionFactory connectionFactory) {
        return IntegrationFlow.from(
                        Jms.messageDrivenChannelAdapter(connectionFactory)
                                .errorMessageStrategy(new DefaultErrorMessageStrategy())
                                .destination(queue)
                                .id("observedJmsIntegrationQueue")
                )
                .handle(msg -> logger.info(msg))
                .get();
    }

looks in my local no compilation error in Java DSL way.

@matthera
Copy link
Author

It was more the non-DSL java configuration I was referencing regarding the compilation error.

However, does the DSL configuration actually work? I don't fully understand how the DSL configuration applies, but from what I can see it calls the setErrorMessageStrategy method on the JmsMessageDrivenEndpoint. Similarly, the JmsMessageDrivenEndpoint proxies all the get/set method to the internal listener (ChannelPublishingJmsMessageListener), except the setErrorMessageStrategy/getErrorMessageStrategy. So surely the error message strategy will just be set on JmsMessageDrivenEndpoint, which is ignored from a functionality point of view?

@mjd507
Copy link
Contributor

mjd507 commented May 20, 2025

thank you, I understand your point now.
you want to propagate the ErrorMessageStrategy from JmsMessageDrivenEndpoint to its internal ChannelPublishingJmsMessageListener , since the listener internally uses a GatewayDelegate with default JmsMessageHeaderErrorMessageStrategy , and you have no way to change the strategy with your own.

@artembilan
Copy link
Member

There cannot be a compilation error because of JmsMessageDrivenEndpoint extends MessageProducerSupport.
So, we can do:


		@Bean
		public JmsMessageDrivenEndpoint inbound() {
			JmsMessageDrivenEndpoint jmsMessageDrivenEndpoint = new JmsMessageDrivenEndpoint(container(), listener());
			jmsMessageDrivenEndpoint.setErrorMessageStrategy(new DefaultErrorMessageStrategy());
			return jmsMessageDrivenEndpoint;
		}

However, I definitely see the problem.

public class JmsMessageDrivenEndpoint extends MessageProducerSupport implements OrderlyShutdownCapable {

	private final ChannelPublishingJmsMessageListener listener;

Where that ChannelPublishingJmsMessageListener has:

private final GatewayDelegate gatewayDelegate = new GatewayDelegate();

Which is the central part to perform all the hard work.
And indeed, the provided ErrorMessageStrategy has to be propagated down here, like we do for many other MessageProducerSupport options.

Your proxy word has confused me originally.

@artembilan artembilan added in: jms and removed status: waiting-for-triage The issue need to be evaluated and its future decided labels May 20, 2025
@artembilan artembilan added this to the 6.5.0 milestone May 20, 2025
spring-builds pushed a commit that referenced this issue May 20, 2025
Fixes: #10046
Issue link: #10046

The `JmsMessageDrivenEndpoint` does not propagate an `ErrorMessageStrategy` down to the `ChannelPublishingJmsMessageListener.GatewayDelegate`

* Expose `JmsMessageDrivenEndpoint.setErrorMessageStrategy()` and call respective `this.listener.setErrorMessageStrategy()`

(cherry picked from commit da1ec07)
spring-builds pushed a commit that referenced this issue May 20, 2025
Fixes: #10046
Issue link: #10046

The `JmsMessageDrivenEndpoint` does not propagate an `ErrorMessageStrategy` down to the `ChannelPublishingJmsMessageListener.GatewayDelegate`

* Expose `JmsMessageDrivenEndpoint.setErrorMessageStrategy()` and call respective `this.listener.setErrorMessageStrategy()`

(cherry picked from commit da1ec07)
@matthera
Copy link
Author

Great - thanks for such a quick turn-around on this one. Really appreciate it.

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

No branches or pull requests

4 participants