Java Reference
In-Depth Information
As you can see in the preceding code snippet, our sample is initialized with IDs from 5 to
9 , and on every GET request, it will provide the ID as the output. When all IDs are emit-
ted, a null value will be returned. This endpoint will serve as a model of a reservation sys-
tem. For simplicity, it produces plaintext values instead of JSON. Of course, a flat file or
any other source of data could also be used for integration.
Creating a chunk-based batch step
Our integration scenario will be pretty straightforward. We need to read all of the reserva-
tion IDs from the external system to get the corresponding seats from our database and
write the changes back to the database. It would also be great to write a log with the oper-
ations made by the import. Let's start with the item reader:
package com.packtpub.wflydevelopment.chapter12.batching;
import javax.batch.api.chunk.AbstractItemReader;
import javax.inject.Named;
public class ExternalSystemReader extends
AbstractItemReader {
private WebTarget target;
public void open(Serializable checkpoint) throws
Exception {
final Client restclient = ClientBuilder.newClient(); ="http://localhost:8080/
public Object readItem() throws Exception {
Search WWH ::

Custom Search