Announcement Announcement Module
Collapse
No announcement yet.
dao for ftp? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • dao for ftp?

    I posted the following query in the spring database forum and then realized that this might be a better question here. But for this forum I guess the question is, will Spring Batch provide a dao wrapper for ftp so that I can define a rollback action for an ftp upload?

    I have a service class that uses a dao to fetch data from a database, then creates a text file of invoices from the data and uploads that via ftp to an IBM mainframe, then goes back to the database via a dao and marks the entries as billed.

    I could treat the ftp upload as a dao as well, and have all 3 operations wrapped in a transaction, so that if any fail all 3 are rolled back.

    For the ftp the roll back would be to reconnect and delete the uploaded file, and this is what I don't understand how to hook up. I'm guessing that there's some interface I need to implement or class to extend in order for my ftp class to be transaction aware so that it can do its roll back.

    Does anyone have any pointers on how to add low level rollback capability?

  • #2
    There isn't any kind of 'FTP Output Source' that could be used. However, I'm curious why you couldn't just output all of your files to a directory and then upload via ftp after the job is complete? Spring Batch provides transactional file output capabilities through the FileOutputSource which would enable this.

    If you really want to code an FtpOutputSource (or dao), you would need to use the Spring TransactionSynchronizationManager class to be notified of commits or rolllbacks by registering a TransactionSynchronization. The one issue with this is that TransactionSychronization's are cleared from the manager after committing. The Spring Batch class BatchTransactionSynchronizationManager helps with this by letting you register synchronizations and resynchronize them all after starting a new transaction.

    Comment


    • #3
      It's kind of political; we don't have any control over the machine where the program will run and have to ask the sysadmins to install an ftp program that does ssl.

      Your description is how it runs now; it's running on a unix box that I'm in charge of and I installed lftp to do the uploads, and the java and ftp programs are wrapped in a shell script that does the ftp upload after the java program does its part.

      But I'm not a sysadmin any more so my machine needs to be turned off at some point and the software needs to move to a centrally managed server.

      When I originally wrote the java program I used the Jakarta Commons Net, but then our mainframe group mandated SSL connections and at that time I couldn't find any java ftp package that did SSL so I went the shell script + lftp route.

      Comment

      Working...
      X