FAQ
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.

Search Discussions

  • Claus Straube at Dec 27, 2010 at 12:42 pm
    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.
  • Kanmisc at Dec 28, 2010 at 2:46 pm
    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("<SEMA-CR-"+rand.nextLong()+"@yy>")).
    to("smtp://localhost:9819?to="myEmailID").
    bean(FileValidator.class, "processFiles").

    when(header("CamelFileName").isEqualTo("template2.html")).
    setHeader("Message-ID",constant("<SEMA-CR-"+rand.nextLong()+"@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.
  • Christian Müller at Dec 28, 2010 at 4:02 pm
    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 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("<SEMA-CR-"+rand.nextLong()+"@yy>")).
    to("smtp://localhost:9819?to="myEmailID").
    bean(FileValidator.class, "processFiles").

    when(header("CamelFileName").isEqualTo("template2.html")).
    setHeader("Message-ID",constant("<SEMA-CR-"+rand.nextLong()+"@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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriescamel
postedDec 27, '10 at 12:20p
activeDec 28, '10 at 4:02p
posts4
users3
websitecamel.apache.org

People

Translate

site design / logo © 2022 Grokbase