Java Reference
In-Depth Information
The structure is pretty straightforward. First, we define a job ID matching the filename
[1] . Next, in the properties section, we set a property logFile with the log.txt
value [2] we used it in our SeatWriter to create an output file [3] . Then, we define
a step with a data chunk. The item-count attribute defines the number of items we
process in one transaction. Finally, we reference our reader, processor, and writer in their
matching tags [4] .
Now, when our job is defined, it is time to start it. To do this, we need to the use the
BatchRuntime's static method, getJobOperator . In order to simplify the solution, we
will use a REST endpoint's GET method as a way to invoke our code:
package com.packtpub.wflydevelopment.chapter12.batching;
import java.util.Properties;
import javax.batch.runtime.BatchRuntime;
import javax.ejb.Stateless;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Stateless
@Path("/job")
public class JobStarter {
@GET
public String start() {
long jobId = BatchRuntime.getJobOperator()
.start("externalSystem", new Properties());
return Long.toString(jobId);
}
}
The JobOperator start method returns a job ID, which is a representation of the
ongoing batch process. We need to provide the name of the file defining the batch job
without the XML extension and a set of runtime parameters.
Note
The properties provided during runtime are not the same as we used earlier! These kinds
of properties are not bound to a specific job (in contrast to the ones defined in the XML
Search WWH ::




Custom Search