我正在将Spring Integration JMS 5.1.3与ActiveMQ一起使用,但发现映射优先级出现错误:
java.lang.IllegalArgumentException: The 'priority' header value must be a Number.
at org.springframework.util.Assert.isTrue(Assert.java:118) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.integration.IntegrationMessageHeaderAccessor.verifyType(IntegrationMessageHeaderAccessor.java:177) ~[spring-integration-core-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.messaging.support.MessageHeaderAccessor.setHeader(MessageHeaderAccessor.java:305) ~[spring-messaging-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.messaging.support.MessageHeaderAccessor.lambda$copyHeaders$0(MessageHeaderAccessor.java:396) ~[spring-messaging-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at java.util.HashMap.forEach(HashMap.java:1289) ~[na:1.8.0_181]
at org.springframework.messaging.support.MessageHeaderAccessor.copyHeaders(MessageHeaderAccessor.java:394) ~[spring-messaging-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.integration.support.MessageBuilder.copyHeaders(MessageBuilder.java:179) ~[spring-integration-core-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.integration.support.MessageBuilder.copyHeaders(MessageBuilder.java:48) ~[spring-integration-core-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.integration.jms.ChannelPublishingJmsMessageListener.onMessage(ChannelPublishingJmsMessageListener.java:327) ~[spring-integration-jms-5.1.3.RELEASE.jar:5.1.3.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:736) ~[spring-jms-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:696) ~[spring-jms-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:674) ~[spring-jms-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:318) [spring-jms-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:257) [spring-jms-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1189) [spring-jms-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1179) [spring-jms-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1076) [spring-jms-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
我的邮件标题如下:
我已禁用入站邮件头的优先级:
@Bean
public DefaultJmsHeaderMapper jmsHeaderMapper() {
final DefaultJmsHeaderMapper mapper = new DefaultJmsHeaderMapper();
{
mapper.setMapInboundDeliveryMode(true);
mapper.setMapInboundExpiration(true);
mapper.setMapInboundPriority(false);
}
return mapper;
}
此问题有解决方案吗?
调试日志中的入站消息:
2019-03-01 09:51:51.278 DEBUG 4224 --- [sage-listener-1] .i.j.ChannelPublishingJmsMessageListener : converted JMS Message [ActiveMQTextMessage {commandId = 19, responseRequired = true, messageId = ID:hot-srv-wso2-01-44620-1551368625113-1:4:3:1:1, originalDestination = null, originalTransactionId = null, producerId = ID:hot-srv-wso2-01-44620-1551368625113-1:4:3:1, destination = queue://extraction-request, transactionId = null, expiration = 0, timestamp = 1551408495720, arrival = 0, brokerInTime = 1551408705168, brokerOutTime = 1551408705172, correlationId = ID:hot-srv-wso2-01-44620-1551368625113-1:3:3:1:1, replyTo = queue://extraction-response, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = null, marshalledProperties = org.apache.activemq.util.ByteSequence@67153d1f, dataStructure = null, redeliveryCounter = 6, size = 0, properties = {Connection=Keep-Alive, User-Agent=Apache-HttpClient/4.1.1 (java 1.5), Host=10.10.15.235:8280, Accept-Encoding=gzip,deflate, jms_type=vn.sps.ias.domain.Response, priority=4, JMS_DESTINATION=ReqOutput, JMS_REPLY_TO=ReqROutput, Content-Length=38, JMS_REDELIVERED=false, Content-Type=application/json, timestamp=1551408705049}, readOnlyProperties = true, readOnlyBody = true, droppable = false, jmsXGroupFirstForConsumer = false, text = {"text":"1 was processed"}}] to integration Message payload []
答案 0 :(得分:0)
对我来说,当我在自定义消息中使用标头“ priority”时,就会出现此问题。
MessageBuilder.withPayload(val).setHeader("priority", true).build();
似乎“优先级”是您不得使用的标头值。
更改为
MessageBuilder.withPayload(val).setHeader("prio", true).build();
为我解决了这个问题。