[SPR-15965] JmsMessagingTemplate is not correctly configured Created: 15/Sep/17  Updated: 15/Jan/19  Resolved: 19/Sep/17

Status: Closed
Project: Spring Framework
Component/s: JMS
Affects Version/s: 4.3.11
Fix Version/s: 4.3.12, 5.0 GA

Type: Bug Priority: Minor
Reporter: Filip Hrisafov Assignee: Stéphane Nicoll
Resolution: Complete Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relate
relates to SPR-15962 TaskExecutorRegistration.getTaskExecu... Closed
Days since last comment: 43 weeks ago
Last commented by a User: true
Last updater: Spring Issuemaster

 Description   

The JmsMessagingTemplate does not set the payload MessageConverter from the JmsTemplate.

The RabbitMessagingTemplate sets the payload converter from the `JmsTemplate`. I think that the same needs to be done for the `JmsMessagingTemplate` as well.

I have also created an issue for Spring Boot #10305 and I was redirected here for the fix.



 Comments   
Comment by Stéphane Nicoll [ 18/Sep/17 ]

Can we take a step back here please? I want to make sure that we're talking about the same problem.

Can you share the exact message converter you set in the JmsTemplate and what kind of outcome you expect if you pass that JmsTemplate to JmsMessagingTemplate?

Comment by Juergen Hoeller [ 18/Sep/17 ]

Looking at this with Stéphane a bit further, we assume that this is about reusing a custom JmsTemplate-configured converter as a payload converter behind JmsMessagingTemplate's default MessagingMessageConverter, provided that no such adapter has been configured on the JmsMessagingTemplate itself. This is exactly what RabbitMessagingTemplate does indeed, and alignment is certainly desirable there. We can implement this the same way, tracking a local converterSet flag and passing the JmsTemplate converter on in JmsMessagingTemplate.afterPropertiesSet if necessary.

Let's address this for 5.0 GA and consider a backport to 4.3.12 (scheduled for a month later).

Comment by Filip Hrisafov [ 18/Sep/17 ]

Sorry, my example in the Spring Boot issue is wrong. After I posted it and I started looking more into it and how I should fix it for me (by providing my own implementation), I saw that doing it like with the `RabbitMessagingTemplate` is the correct way. I didn't update my initial code there (should I, so it is more clear for the future?)

So to sum up, what @Juergen wrote is correct. If the `JmsTemplate` has a converter set and the converter in the `JmsMessagingTemplate` has not been explicitly set the converter from the `JmsTemplate` should be used as the payload converter for the `JmsMessagingTemplate`. Basically the exact same logic as the `RabbitMessagingTemplate` has.

At the time of posting the issue, I didn't know that much about the different types of converters.

Comment by Stéphane Nicoll [ 18/Sep/17 ]

Juergen Hoeller I've pushed a fix on master. Would you please review and backport accordingly? Thanks!

Comment by Juergen Hoeller [ 19/Sep/17 ]

This looks good to me; I'll backport it along with a few other commits tomorrow.

Comment by Filip Hrisafov [ 19/Sep/17 ]

Thanks a lot for doing this so fast, really appreciate it. Looking forward to the next 4.3.12 release

Comment by Spring Issuemaster [ 14/Jan/19 ]

The Spring Framework has migrated to GitHub Issues. This issue corresponds to spring-projects/spring-framework#20517.

Generated at Tue Nov 12 00:21:38 UTC 2019 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.