Jill Orders Miscellaneous Items From an Online Retailer How Message Unit-of-Work Completes the Order

Using Unit-of-Work Message Groups 11-3 The group of messages will be delivered to the user without gaps. That is, all messages in the group will be delivered to the user before messages from any other group or part of no group at all. ■ Rule Four: Single Consumer Consumption The group of messages will be delivered to the same consumer.

11.2.3 Message Unit-of-Work Case Study

This section provides a simple case study for Message Unit-of-Work based on an online order that requires a variety of merchandise from multiple companies.

11.2.3.1 Jill Orders Miscellaneous Items From an Online Retailer

The Megazon online retailer implements a processing design that uses JMS to process customer orders for a variety of merchandise, some of which need to be routed to Megazons partner companies to complete the order. For example, Megazon can directly fulfill book orders, but must re-route some parts of the order for certain electronics or houseware items. Since Megazon is configured to use UOW, items in an order can be routed as UOW messages to these intermediate company destinations before being passed onto Megazons terminal destination where all the UOW messages that comprise the order are gathered before a final invoice can be processed. The Megazon JMS processing system is composed of: ■ A UOW producer sending order fulfillment component messages with the required UOW properties to the appropriate intermediate andor terminal destinations. ■ Intermediate destinations for non-book items, where UOW component messages are processed by consumer andor producer clients before being passed onto the final UOW destination. ■ A UOW terminal destination where the component messages are gathered for final processing. Jill logs into her Megazon account and does some holiday shopping. She chooses a book, flash drive, MP3 player, and a lava lamp and then proceeds to the checkout, and completes the sales transaction.

11.2.3.2 How Message Unit-of-Work Completes the Order

To ensure that all messages in Jills order are processed as a single unit, the order-taking JMS producer client sets UOW properties on her order messages to indicate that they are part of a single unit. These UOW message properties must also be copied by any consumer andor producer clients listening on the intermediate Gadget Planet, Widget World, and Desperate Housewares destinations before they pass the UOW messages onto the terminal destination. Last, the system administrator for Megazon configures the terminal destination to UOW Message Handling Policy parameter to Single Message Delivery. See Section 11.3, How to Create a Unit-of-Work Message Group. The following diagram and corresponding actions demonstrate how Jills order was processed using Message Unit-of-Work. 11-4 Programming JMS for Oracle WebLogic Server Figure 11–1 Workflow for Jills Order Using Unit-of-Work 1. Jill clicks the order button from her shopping cart. 2. The order is split into three messages that use the same unique UOW name: ■ SEQ1, which is routed to the intermediate Gadget Planet queue, where a consumer processes the Flash Drive order before passing SEQ1 onto a producer who then routes it to the intermediate Widget World queue, where a consumer processes the MP3 player order before passing SEQ1 to the terminal Megazon queue for final invoice processing. ■ SEQ2, which is routed to the intermediate Desperate Housewares queue, where a consumer processes the lava lamp order before passing SEQ1 onto a producer who routes it to the Megazon terminal processing queue for final invoice processing. ■ SEQ3, which is routed directly to Megazons terminal queue for book order fulfillment and for final invoice processing. 3. The terminal Megazon queue gathers the three UOW messages before forming them into an ObjectMessage list for delivery to Megazons invoice consumer client. 4. Jill receives an invoice that shows her entire order has been processed.

11.3 How to Create a Unit-of-Work Message Group