You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by keepcl123 <ke...@gmail.com> on 2013/12/28 17:40:36 UTC
File Poller of CSV
Hi ,
I want to do File Poller of CSV, then unmarshaling.like this:
<route>
<from
uri="file:///some/path/to/pickup/csvfiles?delete=true&consumer.delay=10000"
/>
<unmarshal><csv /></unmarshal>
<to uri="bean:myCsvHandler?method=doHandleCsvData" />
</route>
But I also want to get *also *the *file name* in my bean.
How do I do this ?
Thx
--
View this message in context: http://camel.465427.n5.nabble.com/File-Poller-of-CSV-tp5745296.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: File Poller of CSV
Posted by Henryk Konsek <he...@gmail.com>.
Hi,
> I did try it .. and got on the marshal part:
It looks like you are sending String to the CSV marshaller. Am I
right? You need to send CSV-friendly data to CSV formatter, like
List<Map<String,String>> or List<List<String>.
BTW Code of csvReportsHandler bean would make answering your question easier :)
Cheers.
--
Henryk Konsek
http://henryk-konsek.blogspot.com
Re: File Poller of CSV
Posted by keepcl123 <ke...@gmail.com>.
I did try it .. and got on the marshal part:
org.apache.camel.NoTypeConversionAvailableException: No type converter
available to convert from type: java.lang.String to
the required type: java.util.Map with value ILS
[END]
org.apache.camel.NoTypeConversionAvailableException: No
type converter available to convert from type: java.lang.String to
the required type: java.util.Map with value ILS
at
org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:144)
ILS is the first String on the first (and only) csv record
--
View this message in context: http://camel.465427.n5.nabble.com/File-Poller-of-CSV-tp5745296p5745307.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: File Poller of CSV
Posted by Richard Kettelerij <ri...@gmail.com>.
Yep, doHandleCsvData(@Body List<List<String>>
csvData, @Header("CamelFileName") String fileName) should be about right.
The rest of the route also looks good. But why ask if the syntax is right,
just try it :)
On Sat, Dec 28, 2013 at 9:37 PM, keepcl123 <ke...@gmail.com> wrote:
> Hi,
>
> my doHandleCsvData signiture is :
>
> doHandleCsvData(List<List<String>> csvData)
>
> so you are saying I have to so this :
>
> doHandleCsvData(@Body List<List<String>> csvData,
> @Header("CamelFileName") String
> fileName)
>
> ?
>
> And another question :
> how do I write the exchange beck to a csv file ?
>
> Is this the right syntax:
>
> <route>
>
> <from
> uri="file://somefile" />
> <unmarshal>
> <csv />
> </unmarshal>
> <to
> uri="bean:csvReportsHandler?method=doHandleCsvData" />
> <marshal>
> <csv />
> </marshal>
> <to uri="file://fileName=teat.csv" />
> </route>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/File-Poller-of-CSV-tp5745296p5745305.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: File Poller of CSV
Posted by keepcl123 <ke...@gmail.com>.
Hi,
my doHandleCsvData signiture is :
doHandleCsvData(List<List<String>> csvData)
so you are saying I have to so this :
doHandleCsvData(@Body List<List<String>> csvData,
@Header("CamelFileName") String
fileName)
?
And another question :
how do I write the exchange beck to a csv file ?
Is this the right syntax:
<route>
<from
uri="file://somefile" />
<unmarshal>
<csv />
</unmarshal>
<to
uri="bean:csvReportsHandler?method=doHandleCsvData" />
<marshal>
<csv />
</marshal>
<to uri="file://fileName=teat.csv" />
</route>
--
View this message in context: http://camel.465427.n5.nabble.com/File-Poller-of-CSV-tp5745296p5745305.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: File Poller of CSV
Posted by Richard Kettelerij <ri...@gmail.com>.
Add an extra parameter to your doHandleCsvData() method and annotate it
with @Header("CamelFileName"). Like this:
public class MyCsvHandler {
public void doHandleCsvData(@Body String body,
@Header("CamelFileName") String
fileName) {
// your custom logic
}
}
See the Bean Binding page for more info
http://camel.apache.org/bean-binding.html, alos checkout the annotations on
http://camel.apache.org/parameter-binding-annotations.html
Regards,
Richard
On Sat, Dec 28, 2013 at 5:40 PM, keepcl123 <ke...@gmail.com> wrote:
> Hi ,
>
> I want to do File Poller of CSV, then unmarshaling.like this:
> <route>
>
> <from
>
> uri="file:///some/path/to/pickup/csvfiles?delete=true&consumer.delay=10000"
> />
> <unmarshal><csv /></unmarshal>
> <to uri="bean:myCsvHandler?method=doHandleCsvData" />
> </route>
>
> But I also want to get *also *the *file name* in my bean.
> How do I do this ?
>
> Thx
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/File-Poller-of-CSV-tp5745296.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>