You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kanmisc <ka...@gmail.com> on 2010/12/27 13:19:44 UTC

Processing files one by one in camel

Hi

I have usecase saying - in source endpoint i have few files to be processed.
Each file needs to be read by camel route and assigned an unique id and
processed through dedicated beans and the resulting file will be posted to
another endpoint. Then it takes another file and do the same logic.

When i tried this with camel, in the bean where the processed file is being
posted to target endpoint, it goes in loop for the number of files already
exist in the target.

Is there a specific way it can be implemented. Appreciate your help.

Thanks in advance.
-- 
View this message in context: http://camel.465427.n5.nabble.com/Processing-files-one-by-one-in-camel-tp3319274p3319274.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Processing files one by one in camel

Posted by Christian Müller <ch...@gmail.com>.
The route definition is executed once at start up. This means
"setHeader("Message-ID", constant("<SEMA-CR-" + rand.nextLong() + "@yy>"))"
will also executed once and the same message ID is set each time. Use a
processor, bean or scripting language for this requirement.

Cheers,
Christian

On Tue, Dec 28, 2010 at 3:45 PM, kanmisc <ka...@gmail.com> wrote:

>
> Basically I am new to Camel and here is my route.
>
> from("file:data/temp?noop=true").
>  when(header("CamelFileName").isEqualTo("template1.html")).
>  setHeader("Message-ID",constant("<SE...@yy>")).
>  to("smtp://localhost:9819?to="myEmailID").
>  bean(FileValidator.class, "processFiles").
>
> when(header("CamelFileName").isEqualTo("template2.html")).
>  setHeader("Message-ID",constant("<SE...@yy>")).
>  to("smtp://localhost:9819?to="myEmailID").
>  bean(FileValidator.class, "processFiles");
>
> 1) I have 8 such when() class to process the files. It will be assigned an
> unique id an send to localhost smtp server which in turn posts to internal
> fuse bundle which processes the template and logs response in another
> location(say B). From B, I have to read the reponse content and check for
> validity.
>
> Then the camel has to pick the next file and send to localhost smtp and the
> process continues like this for all the files. The problem here is i need
> that unique id assigned to the file for processing in FileValidator since
> that is the only way response file can be differentiated. Response files in
> B are created like "xxxx_<uniqueId1>.html", xxxx_<uniqueId2>.html"... etc.
> Without unique id It is not possible to pick correct file for validations.
>
> I am just wondering is there any way to suspend the file polling when the
> control is delegated to the bean.
> Thanks
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Processing-files-one-by-one-in-camel-tp3319274p3320321.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Processing files one by one in camel

Posted by kanmisc <ka...@gmail.com>.
Basically I am new to Camel and here is my route.

from("file:data/temp?noop=true").
 when(header("CamelFileName").isEqualTo("template1.html")).
 setHeader("Message-ID",constant("<SE...@yy>")).
 to("smtp://localhost:9819?to="myEmailID").
 bean(FileValidator.class, "processFiles").

when(header("CamelFileName").isEqualTo("template2.html")).
 setHeader("Message-ID",constant("<SE...@yy>")).
 to("smtp://localhost:9819?to="myEmailID").
 bean(FileValidator.class, "processFiles");

1) I have 8 such when() class to process the files. It will be assigned an
unique id an send to localhost smtp server which in turn posts to internal
fuse bundle which processes the template and logs response in another
location(say B). From B, I have to read the reponse content and check for
validity. 

Then the camel has to pick the next file and send to localhost smtp and the
process continues like this for all the files. The problem here is i need
that unique id assigned to the file for processing in FileValidator since
that is the only way response file can be differentiated. Response files in
B are created like "xxxx_<uniqueId1>.html", xxxx_<uniqueId2>.html"... etc.
Without unique id It is not possible to pick correct file for validations.

I am just wondering is there any way to suspend the file polling when the
control is delegated to the bean.
Thanks

-- 
View this message in context: http://camel.465427.n5.nabble.com/Processing-files-one-by-one-in-camel-tp3319274p3320321.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Processing files one by one in camel

Posted by Claus Straube <cl...@catify.com>.
Hi,

can you post your route?

On 27.12.2010 13:19, kanmisc wrote:
> Hi
>
> I have usecase saying - in source endpoint i have few files to be processed.
> Each file needs to be read by camel route and assigned an unique id and
> processed through dedicated beans and the resulting file will be posted to
> another endpoint. Then it takes another file and do the same logic.
>
> When i tried this with camel, in the bean where the processed file is being
> posted to target endpoint, it goes in loop for the number of files already
> exist in the target.
>
> Is there a specific way it can be implemented. Appreciate your help.
>
> Thanks in advance.