You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Nibha Kumari <ni...@gmail.com> on 2013/04/22 11:43:26 UTC
Aggregator and splitter
Hi,
I am pretty new to camel. I am using camel 2.4.
I want to aggregate different file format (.pdf,.xml..txt) from same source
(user/dir1) and
then I need to process .xml file what i got after aggregation
and then move all the files into a different directory.
The problem i am facing is I dont know how I get my files after aggregation
for further processing.
if I will use groupExchange=true, then how will I get my files. how should i
split that aggregated Exchange .
Pleases give some suggestions or information.
Thanks in advance.
--
View this message in context: http://camel.465427.n5.nabble.com/Aggregator-and-splitter-tp5731227.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Aggregator and splitter
Posted by Nibs <ni...@gmail.com>.
Thanks Marco,
But your solution wont solve my problem.
the problem is
Like i have several user account in one folder called inbox(user1 ,user2,
user3) and each user have some files .
User1(a.xml,a.txt,a.pdf, any other documents which i have no information ).
and I want to processed all the user same time
and I need to check whether the user have particular type of .xml file or
not. So before proceeding
i just want to be sure that all the files related to user1,user2 ,user3 ,...
are agrreagted
nd once i done that
next step i need to check what inside in aggregation exchange, if it has a
particular .xml than do some transformation and validation and after that i
need to crate a folder called user1 dynamically and then put all the files
together i.e. the processed .xml file along with other documents.so the
output will be like outbox/(user1,user2,..)
<from uri:file:inbox recusive=true"/>
<aggregate groupExchanges="true" completionTimeout="1000">
<correlationExpression>
<simple>(I am using parent directory name here)</simple>
</correlationExpression>
<to uri="mock:aggregated"/>
</aggregate>
Now i want all my files here relevent to particular users say user1,so my
question is how i get my files here from this aggregated exchange
Thanks in advance
--
View this message in context: http://camel.465427.n5.nabble.com/Aggregator-and-splitter-tp5731227p5731243.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Aggregator and splitter
Posted by Marco Westermann <Ma...@gmx.de>.
Hi,
I'm not sure what you are asking about. You may provide some route code
you already have.
The first route you will need is the polling of the file and decission
what kind of file has been found (pdf, txt, xml)
Handle that files in different routes and bring them to the same format.
Send the normalized messages to one endpoint which aggregates them.
here is a minimal example (not tested, read it like pseudo code)
from("file:///user/dir1")
.choice()
.when(header("CamelFileNameOnly").contains(".pdf"))
.to("direct:processPdfFile")
.when(header("camelFileNameOnly").contains(".txt"))
.to("direct:processTextFile")
.when(header("camelFileNameOnly").contains(".xml"))
.to("direct:processXmlFile");
// you need equivalent endpoints to transform txt and pdf files
from("direct:processXmlFile")
.bean(XmlTransformerBean.class, "transformXml")
.to("direct:aggregateMesssages");
from("direct:aggregateMesssages")
// have a look here: http://camel.apache.org/aggregator2.html
.aggregate(new MyXmlAggregatingStrategy()).completionSize(3))
.to("direct:doSomethingWithTheAggregatedMessage");
regards, Marco
Am 22.04.2013 11:43, schrieb Nibha Kumari:
> Hi,
>
> I am pretty new to camel. I am using camel 2.4.
>
> I want to aggregate different file format (.pdf,.xml..txt) from same source
> (user/dir1) and
> then I need to process .xml file what i got after aggregation
> and then move all the files into a different directory.
>
> The problem i am facing is I dont know how I get my files after aggregation
> for further processing.
>
> if I will use groupExchange=true, then how will I get my files. how should i
> split that aggregated Exchange .
>
> Pleases give some suggestions or information.
>
> Thanks in advance.
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Aggregator-and-splitter-tp5731227.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>