The body is empty before to go to the endpoint so adding .convertBodyTo(Map.class) has no effect
Regards, Charles Moulliard Claus Ibsen wrote: > > Hi > > I think you need to convert it to a Map afterwards to get your data. Our > use the iterator on the body (it's a List). > > List list = (List) exchange.getIn().getBody(); > list.iterator() will give you a Map of each row > > > Or add the convertBodyTo (I'm not 100 sure) > from(endpointName.getFileCutasIn()) > .unmarshal(flatpack) > .convertBodyTo(Map.class); > > > Med venlig hilsen > > Claus Ibsen > ...................................... > Silverbullet > Skovsgårdsvænget 21 > 8362 Hørning > Tlf. +45 2962 7576 > Web: www.silverbullet.dk > > -----Original Message----- > From: cmoulliard [mailto:[EMAIL PROTECTED] > Sent: 17. juli 2008 13:36 > To: [email protected] > Subject: Re: Component to read FixedLength file ? > > > Hi James, > > When I try to unmarshall my fixedlenghtwithHeaderTrailer file, the body > which is send to my bean is empty. Is there a bug ? > > Here is the RouteBuilder class > > public class A_ParseAndUnmarshallCutasMessages extends RouteBuilder { > > private static final Log LOG = > LogFactory.getLog(A_ParseAndUnmarshallCutasMessages.class); > private FlatpackDataFormat flatpack; > > @Override > public void configure() { > > getContext().addInterceptStrategy(new Tracer()); > > from(endpointName.getFileCutasIn()) > .unmarshal(flatpack) > .to("bean:convert?methodName=CutasToBabel") > .to(endpointName.getAcceptedCutasQueueIn()); > > } > > @Autowired > public void setFlatpackDataFormat(FlatpackDataFormat fixedFormat) { > this.flatpack = fixedFormat; > } > > } > > And the camel context > > <bean id="flatpackDataFormat" > class="org.apache.camel.component.flatpack.FlatpackDataFormat"> > <property name="definition" > value="com/myApplication/transformation/cutas/in/CUTAS.xml" /> > </bean> > > and the trace : > > 4316656 [Thread: 2 [EMAIL PROTECTED] > INFO org.apache.camel.processor.interceptor.TraceInterceptor - > ID-dell-charles/3853-1216294265750/2-1 -> unmarshal1 > [EMAIL PROTECTED] InOnly > Properties:{CamelCauseException=null, > org.apache.camel.file.lock.name=c:\temp\cutas\input\clientA\ST000355.txt.cameLock, > org.apache.camel.file.lock=sun.nio.ch.FileLockImpl[0:9223372036854775807 > exclusive valid], > [EMAIL PROTECTED] > Headers:{org.apache.camel.file.name=ST000355.txt} BodyType:java.io.File > Body:HBT00032700000327190620071714 > C00111a30571b6b0008Z001412 FIEU BFM 200805271554 > +0000000010000000000009076000000138137A000090760EUR > GBPSS808800714636FIEU > /0008031800000000000000000000000000000000000000000000000000090760000000000000000000000000000000000138137413092007000000000000000000001522000 > 00001522000 000000000000000O 0000000000000000 > > 20070907155200 > > X > C00111a30571b170007B000005 APAA 200805271554 > +0000000001835910000003941700000039417A000332147USD > GBPAGENT188888888BDBTA/0000292200000000000000000000000000000000000000000000000039417GBP000000000000000000000000000000000039417 > > 000000000000000000000000000 00000000000 000000000000000B > 0000000000000000 20070619101000 > > X > C00111a30571a600006B000005 APAA 200805271554 > +0000000001855550000003941700000039417A000052147GBP > GBPAGENT188888888BDBTA/0000292200000000000000000000000000000000000000000000000039417GBP000000000000000000000000000000000039417 > > 000000000000000000000000000 00000000000 000000000000000X > 0000000000000000 20070619101000 > > X > C00111a30571c2a0009B000005 APAA 200805271554 > +0000000001855550000003941700000039417A000052147GBP > GBPAGENT188888888BDBTA/0000292200000000000000000000000000000000000000000000000039417GBP000000000000000000000000000000000039417 > > 000000000000000000000000000 00000000000 000000000000000 > 0000000000000000 20070619101000 > > X > FBT00032700000001190620071714 > 4316890 [Thread: 2 [EMAIL PROTECTED] > DEBUG org.apache.camel.management.InstrumentationProcessor - Recording > duration: 187.148981 millis for exchange: Exchange[FileMessage: > c:\temp\cutas\input\clientA\ST000355.txt] > 4316890 [Thread: 2 [EMAIL PROTECTED] > INFO org.apache.camel.processor.interceptor.TraceInterceptor - > ID-dell-charles/3853-1216294265750/2-1 -> to3 > To[bean:convert?methodName=CutasToBabel] InOnly > Properties:{CamelCauseException=null, > org.apache.camel.file.lock.name=c:\temp\cutas\input\clientA\ST000355.txt.cameLock, > org.apache.camel.file.lock=sun.nio.ch.FileLockImpl[0:9223372036854775807 > exclusive valid], > [EMAIL PROTECTED] > Headers:{org.apache.camel.file.name=ST000355.txt} > BodyType:org.apache.camel.component.flatpack.DataSetList Body:[] > 4316890 [Thread: 2 [EMAIL PROTECTED] > DEBUG org.apache.camel.component.bean.BeanProcessor - >>>> invoking > method > for: Exchange[Message: []] > > Regards, > > Charles > > > > James.Strachan wrote: >> >> FWIW I've just checked in a FlatpackDataFormat; which is a tad easier >> to use. The downside is the data format kinda has to turn the DataSet >> into a List of Maps to make it easier to work with; but at least the >> routes are a bit simpler. e.g. this is from the >> DelimitedWithUnmarshalTest (the convertBodyTo is not required >> currently) >> >> <camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> >> <route> >> <from uri="file://src/test/data/delim?noop=true"/> >> <unmarshal ref="delimitedFormat"/> >> <splitter> >> <simple>in.body</simple> >> <convertBodyTo type="java.util.Map"/> >> <to uri="mock:results"/> >> </splitter> >> </route> >> </camelContext> >> >> <bean id="delimitedFormat" >> class="org.apache.camel.component.flatpack.FlatpackDataFormat"> >> <property name="definition" value="INVENTORY-Delimited.pzmap.xml"/> >> </bean> >> >> 2008/7/15 James Strachan <[EMAIL PROTECTED]>: >>> Yeah - I did ponder if it should be a dataformat or a component; or >>> maybe even both. The bit I wasn't sure about was flatpack really just >>> provides an iterator over rows of the file; I wasn't sure if this >>> properly matched the dataformat model of marshalling or unmarshalling >>> a payload (which currently assumes that unmarshalling generates a >>> single result). >>> >>> Maybe we need to enhance the dataformat concept to work with this use >>> case too? >>> >>> So maybe if we want to process each row of a file we do something >>> like... >>> >>> from("file://whatnot"). >>> >>> unmarshall().flatpack().fixed("locationOftheXMLConfigurationfile.pzmap.xml"). >>> split().body(). >>> to("whatever"); >>> >>> where the split().body() would do the iteration over each DataSet? >>> >>> >>> 2008/7/15 Claus Ibsen <[EMAIL PROTECTED]>: >>>> Hi >>>> >>>> Yes I thought also at first it was a dataformat ;) But how James >>>> created >>>> it it works as if it is a dataformat. You just have to do it in >>>> to..from >>>> from..to steps. >>>> >>>> >>>> from("file://c:/test").to("flatpack:foo: >>>> locationOftheXMLConfigurationfile.pzmap.xml"); >>>> >>>> from("flatpack:foo").to("whatever you want"); >>>> >>>> As a component it gets more attention, as people can find it on the >>>> component list. The dataformats are kinda hidden in the wiki >>>> documentation. >>>> Maybe they need a "dataformat" top menu as well ;) >>>> >>>> Med venlig hilsen >>>> >>>> Claus Ibsen >>>> ...................................... >>>> Silverbullet >>>> Skovsgårdsvænget 21 >>>> 8362 Hørning >>>> Tlf. +45 2962 7576 >>>> Web: www.silverbullet.dk >>>> >>>> -----Original Message----- >>>> From: cmoulliard [mailto:[EMAIL PROTECTED] >>>> Sent: 15. juli 2008 09:32 >>>> To: [email protected] >>>> Subject: Re: Component to read FixedLength file ? >>>> >>>> >>>> Many thanks. >>>> >>>> I will test the integration of this component within Camel. >>>> >>>> Remark : I'm a little confused about how Flatpack has been integrated. >>>> The >>>> project has been integrated like a component but from my point of view, >>>> it >>>> should be integrated (for consistency reason) like a Dataformat. >>>> Because >>>> like the other framework/technology implemented in Camel (JAXB, Artix, >>>> XStream, ....), they transform the content from a format (XML, CSV, >>>> ...) >>>> into another format (Collection of Java objects) >>>> >>>> E.g. >>>> >>>> DataFormat flatpack = new >>>> DataFormat("locationOftheXMLConfigurationfile.pzmap.xml.xml") >>>> >>>> from("file:///c:/test") >>>> .unmarshall(flatpack) >>>> .to("whatever you want") >>>> >>>> Regards, >>>> >>>> Charles >>>> >>>> >>>> >>>> James.Strachan wrote: >>>>> >>>>> BTW trunk has an early spike of a flatpack component. Needs more work, >>>>> but there's a basic fixed-width reader example there for the curious >>>>> >>>>> 2008/7/14 James Strachan <[EMAIL PROTECTED]>: >>>>>> I've raised a JIRA to track this... >>>>>> https://issues.apache.org/activemq/browse/CAMEL-717 >>>>>> >>>>>> 2008/7/14 James Strachan <[EMAIL PROTECTED]>: >>>>>>> 2008/7/14 cmoulliard <[EMAIL PROTECTED]>: >>>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> Is there a component expected to read fixedlength files in Camel >>>>>>>> like >>>>>>>> flatpack (http://flatpack.sourceforge.net/) allow to do it ? >>>>>>> >>>>>>> It should be pretty easy to write a flatpack component. >>>>>>> >>>>>>> there's a commercial tool called Artix Data Services which comes >>>>>>> with >>>>>>> a nice design UI that does this with Camel... >>>>>>> http://activemq.apache.org/camel/artix-data-services.html >>>>>>> >>>>>>> but it'd be nice to have an OSS option :) >>>>>>> >>>>>>> -- >>>>>>> James >>>>>>> ------- >>>>>>> http://macstrac.blogspot.com/ >>>>>>> >>>>>>> Open Source Integration >>>>>>> http://open.iona.com >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> James >>>>>> ------- >>>>>> http://macstrac.blogspot.com/ >>>>>> >>>>>> Open Source Integration >>>>>> http://open.iona.com >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> James >>>>> ------- >>>>> http://macstrac.blogspot.com/ >>>>> >>>>> Open Source Integration >>>>> http://open.iona.com >>>>> >>>>> >>>> >>>> >>>> ----- >>>> Enterprise Architect >>>> >>>> Xpectis >>>> 12, route d'Esch >>>> L-1470 Luxembourg >>>> >>>> Phone +352 25 10 70 470 >>>> Mobile +352 621 45 36 22 >>>> >>>> e-mail : [EMAIL PROTECTED] >>>> web site : www.xpectis.com >>>> -- >>>> View this message in context: >>>> http://www.nabble.com/Component-to-read-FixedLength-file---tp18444614s22882p18459545.html >>>> Sent from the Camel - Users mailing list archive at Nabble.com. >>>> >>>> >>> >>> >>> >>> -- >>> James >>> ------- >>> http://macstrac.blogspot.com/ >>> >>> Open Source Integration >>> http://open.iona.com >>> >> >> >> >> -- >> James >> ------- >> http://macstrac.blogspot.com/ >> >> Open Source Integration >> http://open.iona.com >> >> > > > ----- > Enterprise Architect > > Xpectis > 12, route d'Esch > L-1470 Luxembourg > > Phone +352 25 10 70 470 > Mobile +352 621 45 36 22 > > e-mail : [EMAIL PROTECTED] > web site : www.xpectis.com > -- > View this message in context: > http://www.nabble.com/Component-to-read-FixedLength-file---tp18444614s22882p18506498.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > > ----- Enterprise Architect Xpectis 12, route d'Esch L-1470 Luxembourg Phone +352 25 10 70 470 Mobile +352 621 45 36 22 e-mail : [EMAIL PROTECTED] web site : www.xpectis.com -- View this message in context: http://www.nabble.com/Component-to-read-FixedLength-file---tp18444614s22882p18506999.html Sent from the Camel - Users mailing list archive at Nabble.com.
