O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Spring Batch Essentials

Book Description

Design, develop, and deliver robust batch applications with the power of the Spring Batch framework

In Detail

Spring Batch is an open source, lightweight, and comprehensive solution designed to enable the development of robust batch applications that are vital for enterprise operations.

Packed with real-world examples, this book starts with an insight into the batch applications and Spring Batch offerings. After exploring the architecture and key components, you will learn how to develop and execute a batch application. While gaining insights on the essential configurations and execution techniques for batch jobs, you will learn about the key technical implementations of the read, write, and processing features for different forms of data. Next, you will move on to the key features such as transaction management, job flows, job monitoring, and data sharing across the steps of the executing jobs. Finally, you will learn how Spring Batch can integrate with diverse enterprise technologies and facilitate optimization and performance improvement with scaling and partitioning techniques.

What You Will Learn

  • Understand the infrastructure to design, develop, and execute a batch application
  • Configure batch jobs using XML, Expression Language and annotations, and execute from diverse platforms
  • Develop batch jobs with the essential read, process, and write features different forms of data
  • Get to grips with techniques you can use to manage transactions, control job flows, and utilize data sharing
  • Integrate Spring Batch with other technologies to develop robust batch applications on an enterprise platform
  • Monitor and report the batch job execution updates by accessing live job execution information
  • Optimize scale and performance improvement with parallel processing techniques
  • Perform unit integration and functional testing on Spring Batch applications

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Spring Batch Essentials
    1. Table of Contents
    2. Spring Batch Essentials
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Spring Batch Fundamentals
      1. Introduction to batch applications
      2. Spring Batch and its offerings
      3. Spring Batch infrastructure
        1. Spring Batch components
      4. Job design and executions
      5. Summary
    9. 2. Getting Started with Spring Batch Jobs
      1. Spring Batch XML features
        1. Spring Batch XML namespace
        2. Spring Batch XML tags
      2. Configuring jobs, transactions, and repositories
        1. Job configuration
        2. Step configuration
        3. Tasklet configuration
        4. Chunk configuration
        5. Transaction configuration
        6. Job repository configuration
      3. EL and listeners
        1. Listeners
        2. Job listeners
        3. Step listeners
        4. Item listeners
      4. Executing jobs from the command line and web applications
        1. JobLauncher
        2. Launching a job from a command line
        3. Launching a job from within a web application
        4. Stopping batch jobs gracefully
      5. Schedulers
      6. Summary
    10. 3. Working with Data
      1. Data reading
      2. ItemReader
        1. Reading data from flat files
          1. Fixed width file
          2. FlatFileItemReader
          3. LineMapper
          4. Delimited file
          5. Exceptions from flat file reading
        2. Reading data from XML
        3. Reading data from a database
          1. JdbcCursorItemReader
          2. JdbcPagingItemReader
      3. Data processing
        1. ItemProcessor
        2. Chaining the process
      4. Data writing
        1. ItemWriter
          1. Flat file item writers
            1. LineAggregator
            2. PassThroughLineAggregator
          2. FieldExtractor
          3. Writing delimited files
          4. Writing a fixed width file
          5. XML item writers
        2. Database item writers
          1. JDBC-based database writing
          2. ORM-based database writing
      5. Custom item readers and writers
      6. Summary
    11. 4. Handling Job Transactions
      1. Transactions
      2. Spring Batch transaction management
        1. Tasklet steps
        2. Chunk-oriented steps
        3. Listeners
      3. Customizing the transaction
      4. Transaction patterns
        1. Simple transaction
        2. Global transaction
      5. Summary
    12. 5. Step Execution
      1. Controlling the job flow
        1. Using an exit code
        2. Using a decision logic
      2. Data sharing
        1. Using execution context
        2. Using Spring holder beans
      3. Externalization and termination
        1. Externalization
        2. External flow definition and including it in desired jobs
        3. Inherited jobs mechanism
        4. Termination
          1. Terminating in the COMPLETED state
          2. Terminating in the FAILED state
          3. Terminating in the STOPPED state
      4. Summary
    13. 6. Integrating Spring Batch
      1. Enterprise Integration
      2. Spring Integration
        1. Triggering a batch job to execute
      3. RESTful job processing
      4. Summary
    14. 7. Inspecting Spring Batch Jobs
      1. Batch job monitoring
      2. Accessing execution data
        1. Database
          1. JobRepository
          2. JobLauncher
          3. JobOperator
          4. JobExplorer
      3. Listeners
      4. Web monitoring
      5. Summary
    15. 8. Scaling with Spring Batch
      1. The batch scaling model
      2. The thread model
      3. Parallel processing
      4. Remote chunking
      5. Partitioning
      6. Summary
    16. 9. Testing the Spring Batch
      1. Types of testing for Spring Batch
      2. Unit testing
        1. JUnit
        2. Mockito
      3. Integration testing
        1. Listener-based approach
        2. The StepScopeTestUtils approach
      4. Functional testing
      5. Summary
    17. A. Appendix
      1. Setting up Java
      2. Setting up Eclipse IDE
      3. Setting up the project and its dependencies
      4. Spring Batch Administration
    18. Index