Spring集成迁移3到4(JMS头问题)

时间:2015-11-12 00:47:39

标签: spring spring-integration

我正在将Web应用程序从Spring 3.1迁移到4.1。我们使用:

框架 积分, 批量, 安全, 和Web服务,

在大多数情况下,这是一个相对无痛的过程;但是,我遇到了与Integration有关的一个问题。这个JMS消息:

  

GenericMessage [payload=com.etp.bpm.services.jaxwsbindings.data.ProcessActionInstance@50be7b46,headers={errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@98f5a14,jms_timestamp = 1447280384929,determinantName = SeasonPeriod, replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@98f5a14,processActionName = DerivationExecutionAction,jms_replyTo = HornetQQueue [asyncActionReplyQueue],jms_messageId = ID:4fd881ab-88c2-11e5-a7c1-a7dd640b56cc,timestamp = 1447280384934,id = 505ca511-88d0 -e892-acdf-9bdc4330e68f,JMSXDeliveryCount = 1,jms_redelivered = false, priority = 4 ,determinantTypes = [Raw],jms_correlationId = e82424fd-3dab-4ef1-bad2-9a6ec7356a11_1,groups = [PrimaryDeterminantsGroup,10分钟,每周准备初始设置]}]

导致此错误:

  

java.lang.Exception:'priority'标头值必须是Integer。

当spring尝试验证org.springframework.integration.IntegrationMessageHeaderAccessor中的标头值时,会抛出错误,稍后该过程将失败:

else if (IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER.equals(headerName)
                || IntegrationMessageHeaderAccessor.SEQUENCE_SIZE.equals(headerName)
                || IntegrationMessageHeaderAccessor.PRIORITY.equals(headerName)) {
            Assert.isTrue(Integer.class.isAssignableFrom(headerValue.getClass()), "The '" + headerName
                    + "' header value must be an Integer.");
        }

我们的应用程序中没有任何JMS代码。 Spring创建并处理所有消息,那么如何创建它无法处理的头文件呢?

我认为这可能是集成,集成-jms和jms-api之间的版本不匹配问题,但我已经准备好了所有正确的jar。任何建议将不胜感激。谢谢。 (见下面的堆栈跟踪)

14:38:05,376 INFO  [stdout] (Deferred Command #8) java.lang.Exception: The 'priority' header value must be an Integer.

14:38:05,376 INFO  [stdout] (Deferred Command #8)   at org.springframework.util.Assert.isTrue(Assert.java:65)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.IntegrationMessageHeaderAccessor.verifyType(IntegrationMessageHeaderAccessor.java:109)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.messaging.support.MessageHeaderAccessor.setHeader(MessageHeaderAccessor.java:308)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.messaging.support.MessageHeaderAccessor.copyHeaders(MessageHeaderAccessor.java:393)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.support.MessageBuilder.copyHeaders(MessageBuilder.java:154)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.support.MessageBuilder.copyHeaders(MessageBuilder.java:42)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.jms.JmsOutboundGateway.handleRequestMessage(JmsOutboundGateway.java:691)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:101)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:287)

14:38:05,377 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:245)

14:38:05,378 INFO  [stdout] (Deferred Command #8)   at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)

14:38:05,378 INFO  [stdout] (Deferred Command #8)   at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:150)

14:38:05,378 INFO  [stdout] (Deferred Command #8)   at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:45)

14:38:05,378 INFO  [stdout] (Deferred Command #8)   at org.springframework.messaging.core.AbstractMessagingTemplate.sendAndReceive(AbstractMessagingTemplate.java:42)

14:38:05,378 INFO  [stdout] (Deferred Command #8)   at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:79)

14:38:05,378 INFO  [stdout] (Deferred Command #8)   at org.springframework.messaging.core.AbstractMessagingTemplate.convertSendAndReceive(AbstractMessagingTemplate.java:70)

14:38:05,378 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:321)

14:38:05,378 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceive(MessagingGatewaySupport.java:298)

14:38:05,378 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:414)

14:38:05,378 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:374)

14:38:05,378 INFO  [stdout] (Deferred Command #8)   at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:365)

14:38:05,378 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at com.sun.proxy.$Proxy129.executeAsyncAction(Unknown Source)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at java.lang.reflect.Method.invoke(Method.java:606)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:52)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.aspectj.AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:43)

14:38:05,379 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)

14:38:05,380 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)

14:38:05,380 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

14:38:05,380 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)

14:38:05,381 INFO  [stdout] (Deferred Command #8)   at com.sun.proxy.$Proxy232.executeAsyncAction(Unknown Source)

14:38:05,381 INFO  [stdout] (Deferred Command #8)   at com.etp.bpm.actionservice.BaseActionServiceInvocationCommand.sendRequest(BaseActionServiceInvocationCommand.java:165)

14:38:05,381 INFO  [stdout] (Deferred Command #8)   at com.etp.bpm.actionservice.AffinityCheckActionServiceInvocationCommand.executeCommand(AffinityCheckActionServiceInvocationCommand.java:94)

14:38:05,381 INFO  [stdout] (Deferred Command #8)   at com.etp.bpm.command.AbstractDeferredBpmCommand.call(AbstractDeferredBpmCommand.java:82)

14:38:05,381 INFO  [stdout] (Deferred Command #8)   at com.etp.bpm.command.AbstractDeferredBpmCommand.call(AbstractDeferredBpmCommand.java:1)

14:38:05,381 INFO  [stdout] (Deferred Command #8)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at java.lang.reflect.Method.invoke(Method.java:606)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at com.sun.proxy.$Proxy233.call(Unknown Source)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at java.util.concurrent.FutureTask.run(FutureTask.java:262)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)

14:38:05,382 INFO  [stdout] (Deferred Command #8)   at java.lang.Thread.run(Thread.java:745)

2 个答案:

答案 0 :(得分:0)

不。看起来有人在上游添加了priority标题但是Long,而不是Integer

这就是它停止工作的原因。版本不匹配没什么特别的。

只需扫描您的应用程序中的priority字词,然后尝试弄清楚如何克服它。

其中一条建议可能就像<header-filter header-names="priority">前面的<int-jms:outbound-gateway>一样。

答案 1 :(得分:0)

早期版本的框架未映射入站优先级。

这已添加到4.0 JIRA here

headers.put(IntegrationMessageHeaderAccessor.PRIORITY, jmsMessage.getJMSPriority());

根据the API,它应该是int

但似乎HornetQ使用了其他东西(不确定如何使用API​​)。

正如@Artem所述,您可以将其过滤掉,或者将入站标题映射器中的mapInboundPriority属性设置为false。我们添加了这个布尔值来预测这样的问题。

Documentation is here

请打开一个JIRA Issue,这样我们就可以确切了解HornetQ的设置。或许您可以查看调试器。

这可能是一个HornetQ错误。

感谢。