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
Priority header not mapped to JMS Message #3179
Comments
My workaround: ...
Jms.outboundAdapter(connectionFactory)
.configureJmsTemplate(spec -> spec.jmsMessageConverter(outboundMessageConverter()))
...
// TODO remove once https://github.com/spring-projects/spring-integration/issues/3179 is fixed
private static MessageConverter outboundMessageConverter() {
return new SimpleMessageConverter() {
@Override
@SuppressWarnings({"NullableProblems", "ConstantConditions"})
protected ObjectMessage createMessageForSerializable(Serializable object, Session session) throws JMSException {
if (!(object instanceof Message)) {
throw new IllegalStateException("Unexpected type: " + object.getClass());
}
ObjectMessage message = super.createMessageForSerializable(object, session);
message.setJMSPriority(((Message<?>) object).getHeaders().get(MessageHeaders.PRIORITY, Integer.class));
return message;
}
};
} |
We do map
See
So, consider to enable |
Now I recall the reason: not all JMS providers allow to modify properties like Also pay attention that you have been misled: the
So, we try to check here a Therefore a summary: or stay with your custom Does it make sense? |
Let's say I understood enough of it :-)
Not however in Outbound Channel Adapter or Mapping Message Headers to and from JMS Message Thank you for your help! |
Yep! Indeed it has to be documented. And I definitely think that "Mapping headers" section is the right way to go. Thanks for the pointer! |
Affects Version(s): 5.2.3.RELEASE
The DefaultJmsHeaderMapper copies message headers from Spring Integration Messages to JMS Messages.
According to Mapping Message Headers to and from JMS Message, the
priority
header should be mapped, too:However, this is not tested by DefaultJmsHeaderMapperTests and has been broken 5 years ago.
by this statement:
spring-integration/spring-integration-jms/src/main/java/org/springframework/integration/jms/DefaultJmsHeaderMapper.java
Lines 165 to 166 in e9cfb02
Since
priority
is often a primitive (in my case,org.apache.activemq.command.Message#priority
is abyte
butorg.springframework.integration.jms.StubTextMessage#priority
also usesint
), checking it fornull
doesn't do the trick.Interestingly, there's also
spring-jms
's SimpleJmsHeaderMapper which looks almost identical but behaves correctly (in this case):https://github.com/spring-projects/spring-framework/blob/a4179b479599c62a89b5e67dbfa0d28ad61c638b/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java#L99
The text was updated successfully, but these errors were encountered: