You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Claus Ibsen <cl...@gmail.com> on 2017/05/04 13:31:50 UTC

Re: How to implement DataFormat

Hi

Its up to you how you implement your own data formats. Camel uses the
DataFormat API that has marshal and unmarshal operations.

Whatever you do there is up to you.

From your email it sound like you mix up a few things and its a bit
hard to explain in an email.

The aggreagator EIP is the guy that has this grouped exchange
property. that has nothing to do with data formats.




On Fri, Apr 28, 2017 at 10:48 AM, David Hoffer <dh...@gmail.com> wrote:
> We have several DataFormat implementations that handle a variety of
> compression algorithms.  We use these as beans in routes to
> marshal/unmarshal.  Here is an example unmarshal:
>
> where zip is our Zip DataFormat implementation bean.
>
> <when id="obsRouter-Zip">
>     <simple>${file:name} regex 'obs-.*\.zip'</simple>
>     <unmarshal ref="zip"/>
>     <split>
>         <simple>${header.CamelGroupedExchange}</simple>
>         <!-- to dynamic router -->
>         <bean ref="routeManager" method="route(*)"/>
>     </split>
> </when>
>
>
> And here is a marshall example:
>
> <aggregate strategyRef="codacAggregator" completionSize="1000"
> completionInterval="5000">
>     <correlationExpression>
>         <constant>true</constant>
>     </correlationExpression>
>     <marshal ref="zip"/>
>     <setHeader headerName="CamelFileName">
>         <simple>${file:name}.zip</simple>
>     </setHeader>
>     <to uri="bean:ingestClient"/>
> </aggregate>
>
>
> My question is where is it documented how Camel will call the marshal and
> unmarshal methods?  For example in the following marshal method what will
> Camel set in the Exchange and Object parameters?
>
> void marshal(Exchange exchange, Object graph, OutputStream stream)
> throws Exception
>
> E.g. there has to be some convention of where Camel put all the files that
> are being combined into a single zip file.  Are the files in the Exchange's
> Exchange.GROUPED_EXCHANGE property?  Or are they somehow retrieved via the
> Exchange's getIn()?  I'm looking at some of our existing code and its
> getting from both which seems wrong.  I'm trying to write some unit tests
> for our code and I need to put the files in the same place that Camel will
> put them at runtime but don't see any docs on how Camel handles this.
>
> Then regarding unmarshal its a similar questions where does Camel want me
> to put the un-zipped files?  As a Exchange.GROUPED_EXCHANGE Exchange
> property that has a list of Messages (where each is a file)?  Same if just
> one file?  What about the unmarshal Object return value, any need to set
> that?  If so to what?
>
> Could someone point me in the right direction?
>
> -Dave



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2