在多个线程中处理时,Apache Camel会抛出FileNotFoundException

时间:2015-02-20 08:36:45

标签: apache-camel

我使用以下配置来处理4个并行线程中的文件:

<route id="input-decision" errorHandlerRef="inputDeadLetterHandler">
  <from ref="file:${input.directory}?maxMessagesPerPoll=${input.pollSize}&amp;delay=${input.delay}&amp;move=${input.processedDirectory}/$simple{date:now:yyyy-MM-dd}/$simple{file:name}&amp;sortBy=file:name&amp;renameUsingCopy=true&amp;antExclude=*.tmp"/>
  <threads maxPoolSize="4" poolSize="4">
    <!-- processing file here -->
  </threads>
</route>

它开始在启动后的几秒钟内开始像下面那样不断地抛出异常:

org.apache.camel.TypeConversionException: Error during type conversion from type: java.lang.String to the required type: byte[] with value [Body is file based: GenericFile[send_output_20141210134657_73 145.xml]] due java.io.FileNotFoundException: send_output_20141210134657_73 145.xml
    at org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:566) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:174) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.component.file.FileBinding.loadContent(FileBinding.java:57) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.component.file.GenericFileConverter.genericFileToInputStream(GenericFileConverter.java:123) ~[camel-core-2.14.0.jar:2.14.0]
    at sun.reflect.GeneratedMethodAccessor117.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_71]
    at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_71]
    at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1002) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:59) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:276) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:114) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:72) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:47) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.builder.xml.XPathBuilder.doInEvaluateAs(XPathBuilder.java:876) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.builder.xml.XPathBuilder.evaluateAs(XPathBuilder.java:774) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.builder.xml.XPathBuilder.matches(XPathBuilder.java:157) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:90) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) [camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:118) [camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.processor.Pipeline.access$100(Pipeline.java:43) [camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.processor.Pipeline$1.done(Pipeline.java:136) [camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.processor.ThreadsProcessor$ProcessCall.run(ThreadsProcessor.java:83) [camel-core-2.14.0.jar:2.14.0]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_71]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) [na:1.7.0_71]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_71]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_71]
    at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71]
Caused by: org.apache.camel.RuntimeCamelException: java.io.FileNotFoundException: send_output_20141210134657_73 145.xml
    at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1364) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1006) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:59) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.component.file.GenericFileConverter.convertTo(GenericFileConverter.java:97) ~[camel-core-2.14.0.jar:2.14.0]
    at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source) ~[na:na]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_71]
    at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_71]
    at org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1002) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.impl.converter.StaticMethodFallbackTypeConverter.convertTo(StaticMethodFallbackTypeConverter.java:62) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:316) ~[camel-core-2.14.0.jar:2.14.0]
    at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:165) ~[camel-core-2.14.0.jar:2.14.0]
    ... 27 common frames omitted

删除<threads>元素会有所帮助,但这会降低交换速度。此外,使用seda:端点而不是threads有帮助,但它不能保证重新启动之间的交付,即如果我在处理来自seda:的消息时关闭Camel,它将无法恢复它在启动时,这意味着消息丢失。我也尝试过ActiveMQ,但是同时处理文件似乎有些过分。此外,我还有some problems和ActiveMQ。

0 个答案:

没有答案