Cars Online Part 3 - Calculating Delivery Date
By The Old Toxophilist on Feb 09, 2010
Up until this blog the trail has not been GlassFish ESB (Open ESB)
specific but this entry will delve into the first of the Business
Processes that have been written to back the functionality available
within the Cars Online Application. As mentioned previously the Web
simply the User façade capable of running on any Web Server
using AJAX to access the backing Servlets and hence the underlying
Business Processes. Hence we can, if we choose, run this one multiple
machines with multiple levels of Security.
The first of the Business Processes described, in this entry, is the
Get Delivery Date. One of the key demonstration features of Cars Online
was that we can generate a guaranteed Delivery Date based on the Car
information selected and that this is dynamic based on previous orders.
The Get Delivery Date functionality is provided by the Business
Service bpProductionDeliveryDate.bpel which takes the Car details and
checks a number of summary table generated by an Intelligent Event
Process (IEP) application that is running within the GlassFish
application. The Business Service functionality is quite simple in that
it will retrieve the current, average, delivery time for the Body
Style, Engine, Interior and Exterior for the given car and then simply
take the maximum value and add it to today date and return that as the
delivery date. The IEP generated delivery delivery information can
readily be seen displayed on the pages for Engine, Interior and
as the blue bars within each of the data tables.
Intelligent Event Process
The IEP functionality will be executed for each Order taken through
the system, see later trail entries, and simply aggregates that data of
a time based window. The results of the aggregations are then stores
within a database to be retrieved by the application as necessary. You
will notice from the IEP process below that we aggregate information
for the Engine, Wheels, Interior, Exterior (Colour) and Body style.
Business Service -
The Business Service receives a Message based on the ProductionCom
Common Envelope and the BsiProduction WSDL (See Cars
2) and then simply executes four database queries in
parallel to retrieve the delivery estimate for Body Style, Engine,
Interior and Exterior. If we do not find any information then we will
assign a default value of 0 days to the value and ignore it later.
Once we have retrieved the information we simply check to see which
of the delivery dates is the largest and then add that many days to
today's date. This is achieved using the functionality described in
blog entry "Adjusting
DateTimes in BPEL". Once calculated the Delivery
Date is returned and displayed.
The Business Service is called by the AjaxGetDeliveryDateServlet
Servlet running within the CarsOnlineServerApplication deployment. It
can be seen, from the code below, it simply uses a NetBeans Generated
Web Service Client to call the Web Service having built the appropriate
Common Object structure. In can also be seen from the code below that
this again has no direct ties to the GlassFish ESB Web Service and can
hence run on its own Server.