camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sriramch <sri...@consortemedia.com>
Subject File endpoint and GzipDataFormat question
Date Wed, 24 Jun 2009 00:27:25 GMT

I am using the latest camel 2.0-m2 release. I have a list of gzipped file in
a step within a route. I need to extract the contents from the gzipped
location and then based on 1 of 3 types of tokens in the filename, I need to
pass the extracted filename to 3 different beans. My route looks like the
following:

<camel:route>
 	<camel:from uri="direct:getGippedFiles" />
	<camel:bean ref="gzipDownloader" method="doDownload"/>
	<!-- This produces an ArrayList<String> for the filePaths -->
	<camel:split>
		<camel:simple>body</camel:simple>
		<camel:choice>
					<camel:when >
						<camel:simple>body contains 'Token1'</camel:simple>
						<camel:to uri="file://filename=${body}" />
						<camel:unmarshal ref="gunzip"/>
						<camel:bean ref="bean1" method="myMethod"/>
					</camel:when>
					<camel:when >
						<camel:simple>body contains 'Token2'</camel:simple>
						<camel:to uri="file://filename=${body}" />
						<camel:unmarshal ref="gunzip"/>
						<camel:bean ref="bean2" method="myMethod"/>
					</camel:when>
		</camel:choice>
	</camel:split>
</camel:route>

I have defined the bean gunzip as 
<bean id="gunzip" class="org.apache.camel.model.dataformat.GzipDataFormat"/>

However I get the following exception. 
ERROR [17:24:20,432] - org.apache.camel.processor.Logger.log(207) | Failed
delivery for exchangeId: ID-CM-Latitude-E55-50750-1245802622632-0-1. On
delivery attempt: 0 caught: java.io.IOException: Not in GZIP format
java.io.IOException: Not in GZIP format
	at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:137)
	at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:58)
	at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:68)
	at org.apache.camel.impl.GzipDataFormat.unmarshal(GzipDataFormat.java:46)
	at
org.apache.camel.processor.UnmarshalProcessor.process(UnmarshalProcessor.java:51)

The problem seems to be that the GzipDataFormat:unmarshal method expects an
inputstream and not a string filename. What do I need to change in my route
to have the file opened as a stream for the GzipDataForm:unmarshal method.
Is what I am trying to do a good usecase for the file endpoint and gzip?
This is simple enough to do with java code, but I am trying to avoid writing
any code if I can help.

Thanks
Sriram
-- 
View this message in context: http://www.nabble.com/File-endpoint-and-GzipDataFormat-question-tp24176769p24176769.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message