我使用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]处理交换时出错。交换[消息:[正文为空]]。引起:[java.lang.IndexOutOfBoundsException - Index:0,Size:0] java.lang.IndexOutOfBoundsException:Index:0,Size:0
答案 0 :(得分: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$2.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$1.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
从骆驼2.10.0开始,这个班看起来像:
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);
}
如果收到错误,则表示存在空结果集。因此,当版本(2.11.1)查找column_names时,它会失败。好消息是我仍然可以使用camel-jdbc(2.10.0),并且仍然使用camel-core(2.11.1)而没有任何依赖性问题。所以我现在的修复是使用camel-jdbc(2.10.0)