Java Reference
In-Depth Information
Our first batch job
WildFly comes with an implementation of JSR 352 called JBeret (
https://github.com/jberet/
simply implementing the required interfaces; no additional dependencies are required. All
APIs are already in place in our current samples, so we only need to create some classes
and an XML file to specify the job flow.
As a base for our development in this chapter, it would be best to use the code from
sample import batching job. To keep it simple, let's start by defining an artificial external
service that will provide us with IDs of tickets that should be booked. We can deploy it as
part of our application or as a separate WAR file. This sample is based on a REST end-
point, so be sure to configure JAX-RS in your deployment (for details, check out
Chapter
@Singleton
@Startup
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
@Path("/external")
@Produces(MediaType.TEXT_PLAIN)
public class PendingSeats {
private final Queue<Integer> seats =
new ConcurrentLinkedQueue<>();
@PostConstruct
private void setUp() {
for (int i = 5; i < 10; i++) {
seats.add(i);
}
}
@GET
public Integer getNextSeat() {
return seats.poll();
}
}