使用apache camel

时间:2016-02-18 12:10:18

标签: apache-camel

我尝试使用camel(2.15.1)从数据库中获取blob。数据大小约为20 MB。这是我的路线:

<route streamCache="true">
    <from uri="file://c:/tmp/trigger" />
    <to uri="jdbc:datasourceCosima" />
    <log message="done 1."/>
    <to uri="direct:a" />
</route>

<route streamCache="true">
    <from uri="direct:a" />
    <to uri="file:blobdata" />
    <log message="done 2."/>
</route>

要启动它,我将带有sql命令的文件放在c:/ tmp / trigger中。内容类似于select bls_data from blob_storage where io_id='2fe0...'

结果如下:

[2016-02-18 12:44:15.539] INFO: org.apache.camel.util.CamelLogger log - done 1. 
[2016-02-18 12:44:16.553] SEVERE: org.apache.camel.util.CamelLogger log - Failed delivery for (MessageId: ID-GHD13044-49732-1455793836517-2-2382 on ExchangeId: ID-GHD13044-49732-1455793836517-2-2381). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[org.apache.camel.component.file.GenericFileMessage@7a0613]

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[route9            ] [route9            ] [file://c:/tmp/trigger                                                         ] [      1635]
[route9            ] [to13              ] [jdbc:datasourceCosima                                                         ] [       822]
[route9            ] [log12             ] [log                                                                           ] [         1]
[route9            ] [to14              ] [direct:a                                                                      ] [       813]
[route10           ] [to15              ] [file:blobdata                                                                 ] [       812]

Exchange
---------------------------------------------------------------------------------------------------------------------------------------
Exchange[
    Id                  ID-GHD13044-49732-1455793836517-2-2381
    ExchangePattern     InOnly
    Headers             {breadcrumbId=ID-GHD13044-49732-1455793836517-2-2380, CamelFileAbsolute=true, CamelFileAbsolutePath=c:\tmp\trigger\select.txt, CamelFileContentType=null, CamelFileLastModified=1455793414658, CamelFileLength=179, CamelFileName=select.txt, CamelFileNameConsumed=select.txt, CamelFileNameOnly=select.txt, CamelFileParent=c:\tmp\trigger, CamelFilePath=c:\tmp\trigger\select.txt, CamelFileRelativePath=select.txt, CamelJdbcColumnNames=[bls_data], CamelJdbcRowCount=1, CamelRedelivered=false, CamelRedeliveryCounter=0}
    BodyType            java.util.ArrayList
    Body                [{bls_data=255044462D312E360D25E2E3CFD30D0A3...
]

Stacktrace
--------------------------------------------------------------------------------------------------------------------------------------- 
org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[org.apache.camel.component.file.GenericFileMessage@7a0613]
    at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1635)
    at org.apache.camel.impl.DefaultExchange.setException(DefaultExchange.java:308)
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:64)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:129)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
    at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:51)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:129)
    at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
    at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)
    at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
    at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)
    at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:433)
    at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:211)
    at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:175)
    at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:174)
    at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:101)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:351)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.OutOfMemoryError: Java heap space

我认为streamCache可以完成工作并将数据缓存在光盘或其他任何地方。

所以问题是:如何将数据库中的blob数据转换为没有大小限制的文件?

0 个答案:

没有答案