Java Reference
In-Depth Information
batching framework API gives you many possibilities without too many complications in
the area of job management.
Creating a job-based batch step
Our chunk-based job was great to process big data sets. However, what if we only want to
perform a specific task? Besides creating chunks, we can also define steps that will simply
call a process method of a specific class. These kinds of classes must implement the
Batchlet interface (or extend the AbstractBatchlet class).
In our sample, let's try to contact an external API to ask about the current Bitcoin ex-
change rate (a decentralized, virtual currency). Then, we will store the current prices of
our tickets in a simple flat file. Our batchlet would be as follows:
public class BitcoinTask extends AbstractBatchlet {
private static final String EXTERNAL_API =
public static final String FILENAME_PARAM =
private SeatTypeDao seatTypeDao;
private JobContext jobContext;
public String process() throws Exception { // [1]
WebTarget api =
Response response = api.request().get();
JsonObject entity =
response.readEntity(JsonObject.class); // [2]
double averageValue =
Search WWH ::

Custom Search