concept timing in category java

This is an excerpt from Manning's book Spring Integration in Action.
Many scenarios don’t operate with groups of individual messages that can be aggregated together like the order items that belong to a specific order. They operate in a looser fashion: the groups have certain requirements concerning the numbers or kinds of payloads that must be present in the group before release, but, for example, payload instances of the same kind may be interchangeable. Consider an order trading system: the condition for making a trade and releasing a group of messages is to find a match between the buy (long) and sell (short) orders. For example, broker A places a long order for 1000 shares for Glorp Corporation, and then customer B places a short order for 600 Glorp shares, and customer C places a short order for 400 Glorp shares. These three orders can be fulfilled against each other, but if a customer D then placed a long order of 500 Glorp shares, its order could also be fulfilled against customer B’s short order. The outcome depends greatly on the sequence in which the orders arrive, including timing.
Race conditions like this one are often inevitable because being completely fair is impractical, if not impossible, given the performance requirements. A heuristic approach is a better fit, and various patterns have emerged in an attempt to offer a satisfactory, albeit not ideal, solution. The next two sections focus on two common patterns in aggregation that don’t immediately fall under the straightforward example of taking something apart and putting it back together. The first section explores aggregation based on nothing but timing, and the second section deals with scatter-gather.
Figure 15.3. Fixed-delay polling
versus fixed-rate polling
. A fixed-rate scenario guarantees that polling will happen at the same preset interval, but the gap between poll operations completing and starting may vary. A fixed-delay scenario guarantees that the interval between polls is constant, but the timing of the polling event may drift over time.
![]()
versus fixed-rate polling
. A fixed-rate scenario guarantees that polling will happen at the same preset interval, but the gap between poll operations completing and starting may vary. A fixed-delay scenario guarantees that the interval between polls is constant, but the timing of the polling event may drift over time.