O'Reilly logo

Agile Enterprise Application Development with Flex by Tony Hillerson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Orchestrating Processes with Asynchronous Events

While describing our business scenario, we mentioned that the handleApprovedOrder method of the SupplierProcess activity is initiating an entirely different process between the Supplier and a specific Manufacturer, AndyNailsProcess (see Figures 10-28 and 10-29). In fact, this was both an over- and an understatement at the same time.

It is an overstatement because SupplierProcess does not directly initiate any other processes. It is an understatement because indirectly it may initiate an arbitrary number of the processes—as many as will be willing to listen to the event.

Meet asynchronous events: SupplierProcess simply broadcasts an event per each line of the approved retailer order, as shown in Example 10-34.

Example 10-34. Fragment of SupplierProcess related to dispatching events

public int handleApprovedOrder( String orderId ){
   OrderLineItemDAO orderLineItemDao = new OrderLineItemDAO();
   List<OrderLineItemDTO> orderLineItems = orderLineItemDao.getLineItems(
      orderId
   );
   for ( int i = 0; i < orderLineItems.size(); i++ ){
      OrderLineItemDTO lineItem = orderLineItems.get(i);
      EventsHelper.dispatchLineItemEvent(
         lineItem.LINEITEM_ID, lineItem.MNF_CODE);
   }
   return ORDER_STATUS_APPROVED;
}

How are the processes are being set up to “wake up” based on the broadcast event, and what does it take to actually dispatch these events? These are the topics of the next section.

Defining Events

Asynchronous events look and act much like network messages. They ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required