Java Reference
In-Depth Information
Our first batch job
WildFly comes with an implementation of JSR 352 called JBeret (
jsr352 ) . This means that we can easily extend our ticket application with batch jobs, by
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
Chapter 5 , Combining Persistence with CDI . The persistence layer will allow us to code a
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
7 , Adding Web Services to Your Applications ). This is shown in the following code snippet:
public class PendingSeats {
private final Queue<Integer> seats =
new ConcurrentLinkedQueue<>();
private void setUp() {
for (int i = 5; i < 10; i++) {
public Integer getNextSeat() {
return seats.poll();
Search WWH ::

Custom Search