Hi All,
       Can some one help me in using excel file with consumer template.
I am trying it with a simple route for testing:
            <route id="Generic-Supply-test">
            <from uri="timer://foo?fixedRate=true&amp;period=3000" />
            <setHeader
headerName="comsumerUrl"><simple>file:${properties:inbound_home}/pgsl?include=SOCGEN_2Records.xls</simple></setHeader>
                       <to uri="bean:locatesConsumer?method=consumeFile" />
                       <to
uri="bean:excelParser?method=convertExcelToDelimited" />
            </route>
and locatesConsumer.consume excel file as:

    public void consumeFile(Exchange ex) {   
        String endPointUri=ex.getIn().getHeader("comsumerUrl",
String.class);
        Object body=consumer.receiveBody(endPointUri, 2000,Object.class);
                if (body != null) {
                    ex.getIn().setBody(body);
                }  
    }
Here the file is being polled and body is set to exchange but when I try to
cast it to byste array stream it throws exception:
Error while reading excel fileError during type conversion from type:
org.apache.camel.component.file.GenericFile to the required type: byte[]
with value GenericFile[/home/pgsl/SOCGEN_2Records.XLS] due
java.io.FileNotFoundException: /home/pgsl/SOCGEN_2Records.XLS (No such file
or directory)
My code for convert it to byte stream is as follows:
   public void convertExcelToDelimited(Exchange ex) {       
        try {       
            byte[] b = ex.getIn().getBody(byte[].class);  
            InputStream in = new ByteArrayInputStream(b);       
        } 
    }
Please help if anyone knows the answer.

Thanks,
Sanjeev



--
View this message in context: 
http://camel.465427.n5.nabble.com/Consuming-Excel-File-with-consumer-template-tp5737346.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to