Announcement Announcement Module
Collapse
No announcement yet.
how to start with spring batch Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to start with spring batch

    Hi all,

    I'm an old fashioned host programmer with more than 35 years experience in writing host batches, with cobol, assembler, pl1, JCL.
    My java batches were all simple main classes in a host-like procedural manner. Though they are running fine, I would like to migrate to the modern spring batch world.
    But unfortunately I'm not even understanding the 'hello world' example (after 4 weeks).

    What I need would be an example that reads in a flat file item by item with an Item reader,
    processes each Item with an Item Processor and writes out the processed Item on a flat file with an ItemWriter.
    In addition I need to know how to start such a job ( a detail that I did not find in any helloWorld example, just unit tests for readers and writers)



    greatings from a very frustrated developer

    peter Strotmann
    Dortmund, Germany

  • #2
    @Peter,

    There are a lot of samples that come with spring batch project ( sources ), but I agree there is nothing extremely simple that you can easily jump on and start working with if you have no previous experience.

    The best way that I found lately, that works when I need to quickly get new developers up to speed, is to install a Spring Tool Suite, create a Spring Template Project and choose Spring Batch Template. It'll create a very simplistic Spring Batch project with all the dependencies, example ItemReader, example ItemWriter, and runnable tests. Here is step-by-step on how to get to this project: http://www.dotkam.com/2010/04/06/spr...h-quick-start/

    Once you are up and running, you ( given a use case that you described ) would have to swap item reader and writer for FlatFileItemReader and FlatFileItemWriter. Please refer to this very detailed documentation on flat file processing: http://static.springsource.org/sprin...html#flatFiles.

    Here is how to run a job: http://static.springsource.org/sprin...ml#runningAJob

    Good Luck,
    /Anatoly

    Comment


    • #3
      @litius

      thanks for your quick reply, I fetched the simple batch template project in my sts installation and tried the unitTests.

      ExampleItemReaderTests :-)
      ExampleItemWriterTests :-)
      ExampleItemJobConfigurationTests :-(

      Configuration problem: You cannot use spring-batch-2.0.xsd with Spring Batch 2.1. Please upgrade your schema declarations (or use the spring-batch.xsd alias if you are feeling lucky).

      Maybe the Conf Problem is caused by my 4 weeks old sts-installation:

      SpringSource Tool Suite

      Version: 2.3.3.CI-R5487-B25
      Build Id: 201007290801

      I'm running on linux kubuntu 10.4 (Lucid Lynx)


      peter

      see also the attached stack trace junit.txt

      Comment


      • #4
        The template has a bug in that older version of STS. You can download a newer one (I'm using 2.5.0.M3, and RC1 coming next week) or you can just change the schema declaration to use 2.1 like it says in the error message.

        Comment


        • #5
          JUNITs green

          Hi Dave,

          JUNITs on

          Version: 2.5.0.M3
          Build Id: 201008251000

          are green, a fine basis to proceed

          thanks a lot
          peter

          Comment


          • #6
            Still unable to start a Job

            Hi Anatoly, Hi Dave

            I would like to start the Hallo World example from the command line. In the documentation I found something like

            java CommandLineJobRunner endOfDayJob.xml endOfDay schedule.date(date)=2007/05/05

            What would be the resp. commandline for the halloWorld example, provided CommandLineJobRunner lies in /home/peter/Desktop/opt/spring/spring-batch-2.1.3.RELEASE/dist/spring-batch-core-2.1.3.RELEASE.jar and launch-context.xml is located in /home/peter/Documents/workspace-sts-2.5.0.M3/myBatch/src/main/resources/

            peter

            Comment


            • #7
              still cannot run job

              Originally posted by Dave Syer View Post
              The template has a bug in that older version of STS. You can download a newer one (I'm using 2.5.0.M3, and RC1 coming next week) or you can just change the schema declaration to use 2.1 like it says in the error message.
              Hi Anatoly, Hi Dave

              I would like to start the Hallo World example from the command line. In the documentation I found something like

              java CommandLineJobRunner endOfDayJob.xml endOfDay schedule.date(date)=2007/05/05

              What would be the resp. commandline for the halloWorld example, provided CommandLineJobRunner lies in /home/peter/Desktop/opt/spring/spring-batch-2.1.3.RELEASE/dist/spring-batch-core-2.1.3.RELEASE.jar and launch-context.xml is located in /home/peter/Documents/workspace-sts-2.5.0.M3/myBatch/src/main/resources/

              peter
              Reply With Quote

              Comment


              • #8
                You need to spoend some time setting up your claspath. If you are still using the STS sample project, look at the pom.xml - there are some comments in there describing how to run it from the command line using Maven to build the classpath.

                Comment


                • #9
                  Hi,

                  cd <projDir>
                  mvn exec:java

                  on the command line is working fine

                  thanks from Dortmund,
                  city of the no.1 soccer team in Germany

                  Comment

                  Working...
                  X