All the patterns in this chapter up to this point have had one characteristic in common: They simply recognize that some condition exists and announce that fact with an event. Other independent participants receive these notifications and decide what action to take.
In some situations there is an additional challenge in determining what the appropriate response ought to be (Figure 3-10). Further analysis is required, generally to focus the actions on achieving specific business objectives. Reference data, often containing historical information, is required for the analysis. The result of the analysis is generally one or more directives to actually perform the identified actions.
Figure 3-10: Situational Response Pattern
Consider the case in which there is some form of perishable commodity being sold: fresh produce and meat, seats on a plane, or hotel rooms—anything that becomes worthless if not sold by some point in time. The desired business strategy is to dynamically set the price of the commodity based on the remaining inventory and the time remaining before the commodity becomes worthless. The situation being responded to in these cases is the presence of a potential consumer for the perishable commodity.
The simplistic approach to pricing the commodity is to fix a point in time at which it will be put on sale. The idea is that this will raise demand and ensure that the commodity does not go to waste. The problem with this approach is that it neither maximizes revenue nor minimizes the likelihood that the commodity will go to waste. If the commodity is selling well and will likely sell out, putting it on sale will result in lost revenue. On the other hand, if the commodity is selling very poorly, lowering the price by a set amount at a fixed point in time might not ensure that the commodity actually sells out.
A more sophisticated approach is to track the rate at which the commodity is selling versus the price of the commodity. With this approach, the offering price for the commodity can be adjusted dynamically. This approach is often applied to online product sales. It requires complex-event processing to do the dynamic price adjustments as consumers shop and as commodity inventories change. Note that the rate of sales and the current inventory become part of the reference data—a dynamic part whose currency must be maintained in a timely manner—most likely via events!