Java Reference
In-Depth Information
This is a four-step job. Step 1 prepopulates a JMS queue with data to be read in step 2. 1 Although you
can use any number of input options, using JMS for order delivery is a realistic option for the real world;
so, this example uses it. Step 2 reads from a JMS queue and saves the database so that if an issue occurs
during future processing, you won't lose the order. From there, you execute two different steps in
parallel. One step validates that funds are available for the purchase. The second verifies inventory with
an inventory system. If both of those checks are successful, the order is processed and the pick slip for
the warehouse is generated.
To begin working through this job, let's look at the object model. Specifically, there are three
domain classes: Customer , Order , and OrderItem , as shown in Figure 11-15.
- Customer customer
- List<OrderItem> items
- String creditCardNumber
- String expirationDate
- Date placedOn
- boolean creditValidated
- long id
- long version
- String customerName
- String address
- String city
- String state
- String zip
- long id
- long version
- String itemNumber
- int qty
- BigDecimal price
- boolean inventoryValidated
- Order order
Figure 11-15. Class diagram for a parallel processing job
An Order , as shown in Figure 11-15, consists of a Customer , order-specific information (mostly
payment information), and a list of OrderItem s. Each item the customer is purchasing has an OrderItem
entry in the list containing item-specific information including item number and quantity ordered.
To make this job work, you need to write a small amount of code. Specifically:
OrderGenerator : ItemReader that generates the sample orders for your job
CreditService / InventoryService : Services used as ItemProcessors to validate the
user's credit and validate that you have the inventory to process the order
PickListFormatter : Line aggregator that generates the format required for the
picklists you generate
1 This first step probably doesn't make much sense in the grand scheme of things. It obviously won't go
into your production jobs. Instead, it's a great way to build test data prior to the execution of a job.
Search WWH ::

Custom Search