2013-11-26 67 views
0

我試圖解壓縮一個文件,並用特定的Xpath值分別處理xml文件。以下是Spring DSL。路由之間交換文件

<camel:route id="unzip-file" startupOrder="400"> 
    <from uri="file:{{download.folder}}?move={{download.archive}}&amp;consumer.delay=10000"/> 
    <unmarshal ref="zipFileDataFormat"/> 
    <split streaming="true"> 
     <simple>${body}</simple> 
     <to uri="log:org.apache.camel?level=INFO&amp;showAll=true&amp;multiline=true"/> 
     <to uri="file:{{extract.folder}}"/> 
    </split> 
</camel:route> 

<camel:route id="process-extracted-files" startupOrder="300"> 
    <from uri="file://{{extract.folder}}?noop=true&amp;consumer.delay=10000&amp;delete=false"/> 
    <choice> 
     <when> 
      <simple>${file:ext} regex '(?i)(xml)'</simple> 
      <to uri="direct:process-xml-file"/> 
     </when> 
     <otherwise> 
      <log message="ignoring file ${file:name}, not XML"/> 
     </otherwise> 
    </choice> 
</camel:route> 

<camel:route id="process-xml-file" startupOrder="200"> 
    <from uri="direct:process-extracted-files"/> 
    <log message="processing file ${file:name}" /> 
    <choice> 
     <when> 
      <xpath>/invoices/@region='region1'</xpath> 
      <split> 
       <xpath>/invoices/invoice</xpath> 
       <log message="${body}"/> 
      </split> 
     </when> 
     <otherwise> 
      <log message="ignoring file ${file:name}, not 'region1'"/> 
     </otherwise> 
    </choice> 
</camel:route> 

我在日誌中發現下面的錯誤,不知道我在想什麼。孩子路由定義的

Message History 
--------------------------------------------------------------------------------------------------------------------------------------- 
RouteId    ProcessorId   Processor                  Elapsed (ms) 
[process-extracted-] [process-extracted-] [file://C:/Temp/invoices/extract?consumer.delay=10000&delete=false&noop=true  ] [  353] 
[process-extracted-] [choice1   ] [when[simple{${file:ext} regex '(?i)(xml)'}]choice[]       ] [  354] 
[process-extracted-] [to6    ] [direct:process-xml-file              ] [   5] 

Exchange 
--------------------------------------------------------------------------------------------------------------------------------------- 
Exchange[ 
    Id     ID-crm.bigcorp.co.za-51788-1385461098541-0-4 
    ExchangePattern  InOnly 
    Headers    {breadcrumbId=ID-crm.bigcorp.co.za-51788-1385461098541-0-3, CamelFileAbsolute=true, CamelFileAbsolutePath=C:\Temp\invoices\extract\INVOICES_V2_DAILY_DELTA_20131105.xMl, CamelFileLastModified=1385450517644, CamelFileLength=205502, CamelFileName=INVOICES_V2_DAILY_DELTA_20131105.xMl, CamelFileNameConsumed=INVOICES_V2_DAILY_DELTA_20131105.xMl, CamelFileNameOnly=INVOICES_V2_DAILY_DELTA_20131105.xMl, CamelFileParent=C:\Temp\invoices\extract, CamelFilePath=C:\Temp\invoices\extract\INVOICES_V2_DAILY_DELTA_20131105.xMl, CamelFileRelativePath=INVOICES_V2_DAILY_DELTA_20131105.xMl, CamelRedelivered=false, CamelRedeliveryCounter=0} 
    BodyType   org.apache.camel.component.file.GenericFile 
    Body    [Body is file based: GenericFile[C:\Temp\invoices\extract\INVOICES_V2_DAILY_DELTA_20131105.xMl]] 
] 

Stacktrace 
--------------------------------------------------------------------------------------------------------------------------------------- 
org.apache.camel.component.direct.DirectConsumerNotAvailableException: No consumers available on endpoint: Endpoint[direct://process-xml-file]. Exchange[INVOICES_V2_DAILY_DELTA_20131105.xMl] 

回答

1

更改URI到直接:過程的XML文件(與調用)

<from uri="direct:process-xml-file"/> 
+0

Arrrrrgggghhhh,尖叫聲和拉頭髮然後回到工作。 – n002213f