Closed
Description
Gary Russell opened SPR-13576 and commented
See AMQP-541 - a similar situation to that with the RabbitListener
exists with JmsListener
.
@SpringBootApplication
@EnableTransactionManagement
public class JmsdemoApplication {
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext ctx = SpringApplication.run(JmsdemoApplication.class, args);
JmsTemplate template = ctx.getBean(JmsTemplate.class);
template.convertAndSend("foo", "bar", new MessagePostProcessor() {
@Override
public Message postProcessMessage(Message message) throws JMSException {
message.setJMSCorrelationID("abc");
return message;
}
});
Thread.sleep(5000);
ctx.close();
}
@Bean
public Listener listener() {
return new ListenerImpl();
}
public interface Listener {
public void listen(String payload, @Header("jms_correlationId") String correlationId);
}
@Transactional
public static class ListenerImpl implements Listener {
@Override
@JmsListener(destination="foo")
public void listen(String payload, @Header("jms_correlationId") String correlationId) {
System.out.println(payload + ":" + correlationId);
}
}
@Bean
public PlatformTransactionManager transactionManager() {
return mock(PlatformTransactionManager.class);
}
}
Without @EnableTransactionManagement
output is bar:abc
as expected; when the listener is proxied, we get bar:bar
.
The problem is that the method
in the InvocableHandlerMethod
is the method on the proxy.
With Spring Web, the method is the interface method.
See the discussion on AMQP-541 and its PR for the suggested solution over there (discover the correct interface method to be consistent with Spring Web).
Affects: 4.2.1
Issue Links:
- AMQP-545 Use MethodIntrospector for
@RabbitListener
- AMQP-541
@Header
and@Payload
Annotations Not Recognized on Proxy - Consistent method selection for listeners and endpoint mappings [SPR-13654] #18230 Consistent method selection for listeners and endpoint mappings
- @EventListener does not work if put it at method in class that implements interface [SPR-13650] #18226
@EventListener
does not work if put it at method in class that implements interface
Referenced from: commits da9c80c