Results 1 to 10 of 10

Thread: File System Monitor, is Spring Integration the way to go?

  1. #1
    Join Date
    Aug 2004
    Location
    Santiago, Chile
    Posts
    2

    Default File System Monitor, is Spring Integration the way to go?

    Hi, I'm new to Spring Integration and I would like to know if you guys recommend it for a project I need to start working on and, as usual, with a very tight schedule and budget.
    I need to integrate with a legacy system by reading and writing XML files to a shared directory (and Web-Services from a business partner). Spring Integration provides polling capabilities, right? So all the infrastructure services for reading and writing files to a shared file system directory will be taken care by the framework, right?
    Since I'll be dealing with XML files, XSLT will be needed for transforming between formats. Incoming messages are digitally signed with XML Signature, so I need to validate it, and outgoing messages need to be signed by my application.
    Considering the scenario described above, would you recommend to go with Spring Integration? My guess would be: yes. I really appreciate your input.
    Best Regards,
    Jose M. Selman

  2. #2
    Join Date
    Oct 2007
    Location
    Toronto, ON
    Posts
    90

    Default

    Hey Jose,

    Here's what SI and the file source support can do for you:

    - poll the directory where you receive the files
    - filter the incoming files using the FileFilter
    - create one message for the every files found in a given directory (after message creation, the file will be deleted)
    - send it through a channel as a String message (you can apply an XSL transformation on the payload).

    I guess that this should solve your problem, so the answer based on that is definitely yes.

    -- Marius
    Marius Bogoevici,
    Spring Integration Committer

  3. #3
    Join Date
    Mar 2005
    Posts
    135

    Default

    Indeed, you could even use e.g. JAXB to automatically convert your XML document to a Java POJO if you wish, and it even isn't that hard .

  4. #4

    Default

    - create one message for the every files found in a given directory (after message creation, the file will be deleted)
    I am concerning about this step. If the file is deleted, how we could proceed further on the file.

    Our use case is, we want to monitor on a directory. Upon a new file coming (e.g. product.txt), we want to load the file into database. After that, we will delete the file.

    Any good way from spring integration could offer?

  5. #5
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,854

    Default

    Spring Integration M4 (released earlier today) solves this issue. Files are no longer deleted from the source directory (unless you choose to add such behavior to an interceptor, etc).

    Also, there are 3 supported Message creation strategies out-of-the-box: text, binary, and file - for copying the File to a Message payload of String, byte[], or java.io.File object respectively. In many cases, you may simply want a Spring Integration message to notify some other process that a File is available. The "file" type works nicely for those scenarios (and it is the default).

    Check out the 3 versions in the "filecopy" package of the "org.springframework.integration.samples" project for more detail.

  6. #6

    Default

    Thanks, I downloaded M4 and tested it. It works fine. We would like to know more about how to start the polling process. In the samples, it called context.start() to start the polling process.

    First question is: what is the actual logic to start the polling thread? What is the thread creation logic inside SI infrastructure? new Thread()? or else?

    Second question is: we want to launch this file adapter (i.e. the file poller) inside
    container. Do we have any way to inject thread creation logic? e.g. use WorkManagerTaskExecutor for running inside container case.

  7. #7
    Join Date
    Sep 2004
    Location
    Copenhagen, Denmark
    Posts
    113

    Default

    Quote Originally Posted by Mark Fisher View Post
    Spring Integration M4 (released earlier today) solves this issue. Files are no longer deleted from the source directory (unless you choose to add such behavior to an interceptor, etc).

    Also, there are 3 supported Message creation strategies out-of-the-box: text, binary, and file - for copying the File to a Message payload of String, byte[], or java.io.File object respectively. In many cases, you may simply want a Spring Integration message to notify some other process that a File is available. The "file" type works nicely for those scenarios (and it is the default).

    Check out the 3 versions in the "filecopy" package of the "org.springframework.integration.samples" project for more detail.
    And how do you delete the processed in files in M4?

    Or another real life use-case is actually to move the files to a "backup" folder, on completion.
    /Claus

  8. #8
    Join Date
    Oct 2007
    Location
    Toronto, ON
    Posts
    90

    Default

    Quote Originally Posted by davsclaus View Post
    And how do you delete the processed in files in M4?

    Or another real life use-case is actually to move the files to a "backup" folder, on completion.
    One way to do this is to use the message creation strategy that returns a java.io.File payload. Thus, your handler can know when the message has been processed and can use the File object passed as a payload to read and delete/move the File.

    Hope that helps,
    Marius
    Marius Bogoevici,
    Spring Integration Committer

  9. #9
    Join Date
    Dec 2011
    Posts
    6

    Exclamation Need help to integrate!

    Hi, I am new to spring and I am in need of this file monitoring using Spring Adapters. Can anyone update the functionality with proper resource. TIA

  10. #10
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,854

    Default

    Have a look at the File support section of our reference manual: http://static.springsource.org/sprin...lsingle/#files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •