TimerConsumer [WARN] 处理交换时出错。交换[消息:[正文为空]]
TimerConsumer [WARN] Error processing exchange. Exchange[Message: [Body is null]]
我使用 camel 2.10.0 已经有一段时间了,但我需要升级到 2.11.1 以添加一些功能。但是在我开始之前,我在升级后开始收到此错误。我尝试寻找解决方案,但很难找到。这是我的路线:
<route>
<from uri="timer://lrbTimer?period=10s" />
<setBody>
<constant>Select * from Table </constant>
</setBody>
<to uri="jdbc:DbConnection" />
<filter>
<simple>${in.body} != "[]"</simple>
<process ref="markRecord" />
<to uri="seda:process" />
</filter>
</route>
我收到的消息是:
TimerConsumer [WARN] Error processing exchange. Exchange[Message: [Body is null]]. Caused by: [java.lang.IndexOutOfBoundsException - Index: 0, Size: 0] java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
我想我已经找到问题所在了。首先是堆栈跟踪。
2015-01-30 15:13:47 TimerConsumer [WARN] Error processing exchange. Exchange[Message: [Body is null]]. Caused by: [java.lang.IndexOutOfBoundsException - Index: 0, Size: 0]
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at org.apache.camel.component.jdbc.JdbcProducer.setResultSet(JdbcProducer.java:226)
at org.apache.camel.component.jdbc.JdbcProducer.createAndExecuteSqlStatement(JdbcProducer.java:146)
at org.apache.camel.component.jdbc.JdbcProducer.processingSqlBySettingAutoCommit(JdbcProducer.java:82)
at org.apache.camel.component.jdbc.JdbcProducer.process(JdbcProducer.java:63)
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.SendProcessor.doInAsyncProducer(SendProcessor.java:122)
at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:298)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:117)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.interceptor.BacklogTracerInterceptor.process(BacklogTracerInterceptor.java:84)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:391)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:273)
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:335)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:135)
at org.apache.camel.component.timer.TimerConsumer.run(TimerConsumer.java:63)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
所以我深入研究了 org.apache.camel.component.jdbc.JdbcProducer.setResultSet
从 camel 2.10.0 开始,这个 class 看起来像:
protected void setResultSet(Exchange exchange, ResultSet rs) throws SQLException {
List<Map<String, Object>> data = extractResultSetData(rs);
exchange.getOut().setHeader(JdbcConstants.JDBC_ROW_COUNT, data.size());
exchange.getOut().setBody(data);
}
在 camel 2.11.1 中它看起来像这样:
protected void setResultSet(Exchange exchange, ResultSet rs) throws SQLException {
List<Map<String, Object>> data = extractResultSetData(rs);
exchange.getOut().setHeader(JdbcConstants.JDBC_ROW_COUNT, data.size());
exchange.getOut().setHeader(JdbcConstants.JDBC_COLUMN_NAMES, data.get(0).keySet());
exchange.getOut().setBody(data);
}
收到错误的情况是结果集为空。所以当 version(2.11.1) 寻找 column_names 它失败了。好消息是我仍然可以使用 camel-jdbc(2.10.0),并且仍然可以使用 camel-core(2.11.1) 而没有任何依赖性问题。所以我现在的解决方法是使用 camel-jdbc(2.10.0)
我使用 camel 2.10.0 已经有一段时间了,但我需要升级到 2.11.1 以添加一些功能。但是在我开始之前,我在升级后开始收到此错误。我尝试寻找解决方案,但很难找到。这是我的路线:
<route>
<from uri="timer://lrbTimer?period=10s" />
<setBody>
<constant>Select * from Table </constant>
</setBody>
<to uri="jdbc:DbConnection" />
<filter>
<simple>${in.body} != "[]"</simple>
<process ref="markRecord" />
<to uri="seda:process" />
</filter>
</route>
我收到的消息是:
TimerConsumer [WARN] Error processing exchange. Exchange[Message: [Body is null]]. Caused by: [java.lang.IndexOutOfBoundsException - Index: 0, Size: 0] java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
我想我已经找到问题所在了。首先是堆栈跟踪。
2015-01-30 15:13:47 TimerConsumer [WARN] Error processing exchange. Exchange[Message: [Body is null]]. Caused by: [java.lang.IndexOutOfBoundsException - Index: 0, Size: 0]
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at org.apache.camel.component.jdbc.JdbcProducer.setResultSet(JdbcProducer.java:226)
at org.apache.camel.component.jdbc.JdbcProducer.createAndExecuteSqlStatement(JdbcProducer.java:146)
at org.apache.camel.component.jdbc.JdbcProducer.processingSqlBySettingAutoCommit(JdbcProducer.java:82)
at org.apache.camel.component.jdbc.JdbcProducer.process(JdbcProducer.java:63)
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.SendProcessor.doInAsyncProducer(SendProcessor.java:122)
at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:298)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:117)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.interceptor.BacklogTracerInterceptor.process(BacklogTracerInterceptor.java:84)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:391)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:273)
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:335)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:46)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:135)
at org.apache.camel.component.timer.TimerConsumer.run(TimerConsumer.java:63)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
所以我深入研究了 org.apache.camel.component.jdbc.JdbcProducer.setResultSet
从 camel 2.10.0 开始,这个 class 看起来像:
protected void setResultSet(Exchange exchange, ResultSet rs) throws SQLException {
List<Map<String, Object>> data = extractResultSetData(rs);
exchange.getOut().setHeader(JdbcConstants.JDBC_ROW_COUNT, data.size());
exchange.getOut().setBody(data);
}
在 camel 2.11.1 中它看起来像这样:
protected void setResultSet(Exchange exchange, ResultSet rs) throws SQLException {
List<Map<String, Object>> data = extractResultSetData(rs);
exchange.getOut().setHeader(JdbcConstants.JDBC_ROW_COUNT, data.size());
exchange.getOut().setHeader(JdbcConstants.JDBC_COLUMN_NAMES, data.get(0).keySet());
exchange.getOut().setBody(data);
}
收到错误的情况是结果集为空。所以当 version(2.11.1) 寻找 column_names 它失败了。好消息是我仍然可以使用 camel-jdbc(2.10.0),并且仍然可以使用 camel-core(2.11.1) 而没有任何依赖性问题。所以我现在的解决方法是使用 camel-jdbc(2.10.0)