Reputation: 7937
I trying to unzip a file and separately process xml files with a specific Xpath value. Below is the Spring DSL.
<camel:route id="unzip-file" startupOrder="400">
<from uri="file:{{download.folder}}?move={{download.archive}}&consumer.delay=10000"/>
<unmarshal ref="zipFileDataFormat"/>
<split streaming="true">
<simple>${body}</simple>
<to uri="log:org.apache.camel?level=INFO&showAll=true&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&consumer.delay=10000&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>
I'm getting the error below in the logs, any idea what i'm missing.
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]
Upvotes: 0
Views: 1167
Reputation: 1361
Change URI of the child route definition to direct:process-xml-file (same as invocation)
<from uri="direct:process-xml-file"/>
Upvotes: 1