在我的一个项目中,我遇到了一个问题,该问题并非总是可以重现,但会不断产生问题。我将在这里解释重要的部分:
该项目正在部署在Apache Karaf中。
第一条路线:
...
...
.to("prs-producer:queue:raw.token.passes")
第二条路线: 第1步中传入的数据具有依赖性,因此需要在飞行中对其进行充实。
from("prs-consumer:queue:raw.token.passes")
.enrich("dw:SELECT TOP 1 Id FROM base.Orders WHERE SourceId = :#OrderId?outputType=SelectOne", new DependencyAggregationStrategy("OrderId"))
.enrich("dw:SELECT TOP 1 Id FROM base.Campaigns WHERE SourceId = :#CampaignId?outputType=SelectOne", new DependencyAggregationStrategy("CampaignId"))
第一条和第二条路线在Karaf中部署为不同的jar文件。
从第二条路线可以明显看出,该项目取决于订单和广告系列。因此,在这些jar(routes)之前部署此路由会导致以下错误。
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)
[route9 ] [route9 ] [prseai-consumer://queue:raw.token.passes ] [ 2]
[route9 ] [enrich7 ] [enrich[constant{prsdw:SELECT TOP 1 Id FROM base.SourceTable WHERE SourceId = ] [ 1]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.NullPointerException: null
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | modelmbean | - - | Entry
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | CamelInternalProcessor | 50 - org.apache.camel.camel-core - 2.21.2 | Exchange processed and is continued routed synchronously for exchangeId: ID-brckner-ThinkPad-T480-1534972104151-2-451 -> Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451]
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | Pipeline | 50 - org.apache.camel.camel-core - 2.21.2 | Processing exchangeId: ID-brckner-ThinkPad-T480-1534972104151-2-451 is continued being processed synchronously
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | modelmbean | - - | Returning 5 fields
2018-08-22T23:14:14,006 | DEBUG | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | Pipeline | 50 - org.apache.camel.camel-core - 2.21.2 | Message exchange has failed: so breaking out of pipeline for exchange: Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451] Exception: java.lang.NullPointerException
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | Pipeline | 50 - org.apache.camel.camel-core - 2.21.2 | Processing complete for exchangeId: ID-brckner-ThinkPad-T480-1534972104151-2-451 >>> Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451]
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | modelmbean | - - | Exit
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | DefaultUnitOfWork | 50 - org.apache.camel.camel-core - 2.21.2 | UnitOfWork afterRoute: route9 for ExchangeId: ID-brckner-ThinkPad-T480-1534972104151-2-451 with Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451]
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | CamelInternalProcessor | 50 - org.apache.camel.camel-core - 2.21.2 | route: Recording duration: 2 millis for exchange: Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451]
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | modelmbean | - - | Printing 5 fields
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | DefaultUnitOfWork | 50 - org.apache.camel.camel-core - 2.21.2 | UnitOfWork done for ExchangeId: ID-brckner-ThinkPad-T480-1534972104151-2-451 with Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451]
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | modelmbean | - - | Exit returning descriptorType=operation, displayName=suspend, mask=false, name=suspend, role=operation
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | EventHelper | 50 - org.apache.camel.camel-core - 2.21.2 | Notifier: org.apache.camel.core.osgi.OsgiCamelContextPublisher@3e78b77b is not enabled for the event: ID-brckner-ThinkPad-T480-1534972104151-2-451 exchange failure: Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451] cause java.lang.NullPointerException
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | CamelInternalProcessor | 50 - org.apache.camel.camel-core - 2.21.2 | Exchange processed and is continued routed synchronously for exchangeId: ID-brckner-ThinkPad-T480-1534972104151-2-451 -> Exchange[ID-brckner-ThinkPad-T480-1534972104151-2-451]
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | MBeanInfoAssembler | 50 - org.apache.camel.camel-core - 2.21.2 | Assembled operation: ModelMBeanOperationInfo: suspend ; Description: Suspend Service ; Descriptor: descriptorType=operation, displayName=suspend, mask=false, name=suspend, role=operation ; ReturnType: void ; Signature:
2018-08-22T23:14:14,006 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | EndpointMessageListener | 50 - org.apache.camel.camel-core - 2.21.2 | onMessage.process END
2018-08-22T23:14:14,007 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | EndpointMessageListener | 50 - org.apache.camel.camel-core - 2.21.2 | onMessage END throwing exception: java.lang.NullPointerException
2018-08-22T23:14:14,006 | TRACE | Blueprint Event Dispatcher: 1 | modelmbean | - - | Constructor
2018-08-22T23:14:14,007 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | BundleDelegatingClassLoader | 48 - org.apache.camel.camel-blueprint - 2.21.2 | LoadClass: org.apache.camel.component.jms.EndpointMessageListener, resolve: false
2018-08-22T23:14:14,007 | TRACE | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | BundleDelegatingClassLoader | 48 - org.apache.camel.camel-blueprint - 2.21.2 | FindClass: org.apache.camel.component.jms.EndpointMessageListener
2018-08-22T23:14:14,007 | DEBUG | Blueprint Event Dispatcher: 1 | modelmbean | - - | Null Descriptor, creating new.
2018-08-22T23:14:14,007 | WARN | Camel (passes-staging-producer) thread #9 - JmsConsumer[raw.token.passes] | EndpointMessageListener | 50 - org.apache.camel.camel-core - 2.21.2 | Execution of JMS message listener failed. Caused by: [org.apache.camel.RuntimeCamelException - java.lang.NullPointerException]
org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1830) ~[50:org.apache.camel.camel-core:2.21.2]
at org.apache.camel.component.jms.EndpointMessageListener$EndpointMessageListenerAsyncCallback.done(EndpointMessageListener.java:196) ~[51:org.apache.camel.camel-jms:2.21.2]
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:117) ~[51:org.apache.camel.camel-jms:2.21.2]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:719) ~[106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:649) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1166) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1158) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1055) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.lang.NullPointerException
而且,正如我所说,此错误并非总是可重现的。过去或现在有人遇到过此类问题吗?在这个问题上获得一些指导将是很棒的。
编辑-其他日志:
Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId ProcessorId Processor Elapsed (ms)
[route42 ] [route42 ] [prseai-consumer://queue:raw.token.passes ] [ 0]
[route42 ] [enrich21 ] [enrich[constant{prsdw:SELECT TOP 1 Id FROM base.Orders WHERE SourceId = ] [ 0]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.NullPointerException: null
2018-08-19T17:41:19,576 | WARN | Camel (prseai-passes-staging-producer) thread #48 - JmsConsumer[raw.token.passes] | EndpointMessageListener | 50 - org.apache.camel.camel-core - 2.20.3 | Execution of JMS message listener failed. Caused by: [org.apache.camel.RuntimeCamelException - java.lang.NullPointerException]
org.apache.camel.RuntimeCamelException: java.lang.NullPointerException
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1831) ~[50:org.apache.camel.camel-core:2.20.3]
at org.apache.camel.component.jms.EndpointMessageListener$EndpointMessageListenerAsyncCallback.done(EndpointMessageListener.java:195) ~[51:org.apache.camel.camel-jms:2.20.3]
at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:116) ~[51:org.apache.camel.camel-jms:2.20.3]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:719) ~[106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:649) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1166) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1158) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1055) [106:org.apache.servicemix.bundles.spring-jms:4.3.14.RELEASE_1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.lang.NullPointerException
2018-08-19T17:41:19,576 | ERROR | Camel (prseai-passes-staging-producer) thread #48 - JmsConsumer[raw.token.passes] | DefaultErrorHandler | 50 - org.apache.camel.camel-core - 2.20.3 | Failed delivery for (MessageId: ID-brckner-ThinkPad-T480-1534693238999-33-43460 on ExchangeId: ID-brckner-ThinkPad-T480-1534693238999-33-43459). Exhausted after delivery attempt: 1 caught: java.lang.NullPointerException
我们正在使用Active MQ 5.15.3和Camel 2.20.3。 谢谢, 库萨尔。