Enterprise Integration Zone is brought to you in partnership with:

Gaurav is a senior software engineer with a passion for learning. He is an evangelist of new technologies and loves to go beyond the same old day to day work and find new and innovative ways to do the same things more effectively. Gaurav has posted 4 posts at DZone. You can read more from them at their website. View Full User Profile

Java EE Batch Applications in NetBeans IDE

09.03.2014
| 3570 views |
  • submit to reddit
This article demonstrates how to define a simple job (JSR 352) using the jBatch Suite in NetBeans  IDE and how to implement the corresponding batch artifacts. 

               Downloadhttp://plugins.netbeans.org/plugin/55031/jbatch-suite 

Abstract

    • Job
    • Batchlet  
    • Decision
    • Transition - Next
    • Flow

Introduction

Batch processing is execution of series of "jobs" that is suitable for non-interactive, bulk-oriented and long-running tasks.Typical examples are end-of-month bank statement generation, end-of-day jobs such as interest calculation, and ETL (extract-transform-load) in a data warehouse. 

JSR - 352

JSR 352 defines a Job Specification Language (JSL) to define batch jobs, a set of interfaces that describes the artifacts that comprise the batch programming model to implement batch business logic . Using jBatch Suite developer may design JSL and generate Job file & source code (batch artifatcs ) .

Job

A Job is an instance that encapsulates an entire batch process.A job is typically put together using a Job Specification Language and consists of multiple steps. The Job Specification Language for JSR 352 is implemented with XML and is referred as "Job XML".

Step

With JSR 352, a Job is simply a container for Steps. It combines multiple steps that belong logically together in a flow . Each step may be either a chunk type step or batchlet type step.

Batchlet

The batchlet element specifies a task-oriented batch step. It is mutually exclusive with the chunk element. Steps of this type are useful for performing a variety of tasks that are not item-oriented, such as executing a command or doing file transfer.


Test your first Job file

The batch job is not automatically started when the application is deployed. A batch job must be initiated explicitly, say, from a servlet or from an Enterprise JavaBeans (EJB) timer or an EJB business method.

JobOperator provides an interface to manage all aspects of job processing, including operational commands, such as start, restart, and stop, as well as job repository commands, such as retrieval of job and step executions.

BatchRuntime.getJobOperator().start("myJob", new Properties());
The batch runtime loads the batch artifacts you specify in your JSL and runs the job on a separate thread. All steps in your job run on the same thread unless you are using partitions or splits. 

Decision

A decision provides a customized way of determining sequencing among steps, flows, and splits.A decision batch artifact decide the next transition. The decision uses any of the transition elements, stop, fail, end, and next elements to select the next transition.


Next Transition

The next element is used to transition the current decision to the next execution element. Multiple next elements may be specified in the current containment scope.

Flow

A flow defines a sequence of execution elements(step, flow, decision, and split) that execute together as a unit. When the flow is finished, it is the entire flow that transitions to the next execution element.  A flow may transition to a step, split, decision, or another flow.

 

Reference

Published at DZone with permission of its author, Gaurav Gupta. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)