Announcement Announcement Module
No announcement yet.
Fully configurable Batch jobs? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fully configurable Batch jobs?


    I'm just trying to figure out if I can use Spring Batch for the following scenario:

    I have to write a simple prog that does some schedulable data transformation jobs, i.e. read data from one database and write them into another.
    The program must be configurable in the way that all datasources (input and output) and all tables and fields must be configurable in a .properties (or .xml) file.

    The point is, I don't have any information about the data i have to transfer at coding time. The tool must be general enough to accept jobs only configured in config files.

    1. Is spring batch usable for that task?
    2. How do I do this?



  • #2
    You might have to write some code - most batch applications have business logic that the framework cannot know in advance. If I were you I would review the existing ItemProvider/Processor and Input/OutputSource implementations and choose ones that are close to your needs. If you think you have a generic use case, please try it out and provide more details of how the framework could specifically support you.


    • #3
      What kind of 'datasources' are you referring to?

      Assuming it's not something crazy like EBCDIC, Spring Batch should be able to help. However, there would need to be a bit of custom logic on your part to load up the different configurations depending upon runtime data. You *could* write your own logic to read in and parse properties or .xml, but I would prefer to let Spring do that for me. I would pass in the name of a spring application context at runtime, that contained your configured Input and Output Sources. From that point you could either load in the application context within your Tasklet, or create a custom Launcher that would add your Application Context to the one created, and use autowiring. If you're using java 5 and spring 2.5, you could also use annotations.

      Hope this helps, let me know if you have more questions about the specific implementation.


      • #4
        can i load spring configuration files from database ?


        i have many application which uses lot of config files, we are planning to store the config files in database and i need help in loading the config files from database using spring.


        • #5
          There are probably standard spring mechanisms for loading a bean factory from a database, however, I would implement this by creating another implementation of the JobConfigurationLocator interface (note: JobConfiguration was renamed to Job in the current snapshot release)

          The JobConfigurationLocator is what SimpleJobLauncher uses to access JobConfiguration classes (which is what jobs are defined in, within xml) The only current implementation is a Map version that has JobConfigurations 'registered' via a postprocessor in the application context. However, you could easily write an implementation that went to the database and reconstituted a JobConfiguration.