gpt4 book ai didi

java - Apache camel 同时处理两个 csv 文件

转载 作者:行者123 更新时间:2023-11-29 09:13:34 25 4
gpt4 key购买 nike

我正在尝试处理两个 .csv 文件并将它们的数据保存到数据库中。我使用的是 java dsl 而不是 springs。

为了更好地解释场景:
我正在读取两个 .csv 文件并处理它们以将它们的数据上传到 sql 数据库中。我为此执行的步骤是

  1. 在 servlet 容器文件中指定引擎初始化程序。
  2. 创建一个EngineInitialiser
  3. 将 EngineInitialiser 绑定(bind)到核心引擎。
  4. 创建将数据保存到数据库所需的 dao 文件。
  5. 创建定义绑定(bind)的引擎模块。
  6. 定义定义文件特定格式的文件。

但是,问题是

尝试将交换解码为 BindyCsvDataFormat 时出现问题。有两种格式的类文件,我已经指定了一种用于 file1 输入文件,另一种用于 file2.csv

现在 bindy 正在尝试将格式映射到父类文件。但是,当它获取 file1.csv 时,它将它映射到同一包下定义的 model1 和 model2。但是,它应该只映射到一个类。如何强制它只映射到一个格式类?

错误如下:

java.lang.IllegalArgumentException: Some fields are missing (optional or mandatory), line: 1 at org.apache.camel.dataformat.bindy.BindyCsvFactory.bind(BindyCsvFactory.java:215) atorg.apache.camel.dataformat.bindy.csv.BindyCsvDataFormat.unmarshal(BindyCsvDataFormat.java:169)atorg.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:58) 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.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:71)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:333) at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:223) at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45) at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90) at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:304) 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:45) 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:50) 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:71) at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:352) at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:175) at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:136) at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:138) at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:90) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) |#]

最佳答案

不同的bindy模型需要使用不同的包名。这是目前的限制, future 会改进。

关于java - Apache camel 同时处理两个 csv 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10943445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com