Announcement Announcement Module
Collapse
No announcement yet.
File System Monitor, is Spring Integration the way to go? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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 .

      Comment


      • #4
        - 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?

        Comment


        • #5
          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.

          Comment


          • #6
            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.

            Comment


            • #7
              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.

              Comment


              • #8
                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

                Comment


                • #9
                  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

                  Comment


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

                    Comment

                    Working...
                    X