简体   繁体   中英

spring integration migration 3 to 4 (JMS header issues)

I'm in the process of migrating a web application from spring 3.1 to 4.1. We use:

Framework, Integration, Batch, Security, and Web Services,

For the most part, it has been a relatively painless process; however, I am stuck on one issue with Integration. This JMS message:

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 minutes, Weekly Prep Initial Settings]}]

is leading to this error:

java.lang.Exception: The 'priority' header value must be an Integer.

When spring tries to verify the header value in org.springframework.integration.IntegrationMessageHeaderAccessor, the error is thrown and later the process fails:

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.");
        }

We don't have any JMS code in our application. Spring creates and handles all the messages, so how it it creating a header it can't handle?

I thought it might be a version mismatch issue between integration, integration-jms, and jms-api, but I have all the correct jars in place. Any advice would be greatly appreciated. Thanks. (see stack trace below)

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)

Nope. It looks like someone upstream adds priority header but as a Long , not Integer .

That's why it stops to work. Nothing special around version mismatch.

Just scan your application for the priority word and try to figure out how to overcome it.

One of suggestion can be like <header-filter header-names="priority"> just in front of <int-jms:outbound-gateway> .

Earlier versions of the framework did not map the inbound priority.

This was added in 4.0 JIRA here .

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

According to the API , it should be an int .

But it seems that HornetQ uses something else (not exactly sure how, given the API).

As a work-around, as @Artem said, you can filter it out, or set the mapInboundPriority property on the inbound header mapper to false . We added this boolean in anticipation of problems such as this.

Documentation is here .

Please open a JIRA Issue so we can figure out exactly what HornetQ is setting it to. Or perhaps you can take a look in a debugger.

It could be a HornetQ bug.

Thanks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM