Warning
This, by no stretch of the imagination, is meant to control life weaponery, or even machinery for that matter... this is meant as a training exercise ONLY!
CEP Example, a Missile Launch Control
Technical Complexity
Medium
Purpose
- Allow the triggering of an outbound event, when receiving multiple synchronous inbound events.
- Provide a sample of an CEP processing, where the interrellation of multiple events is what is of business relevance, and not a single event.
Situation
We've all seen the war movies (or end of the world movies...) where you have two soldiers that have to secure the launch, and press a button at the same time for a missile launch to occur. We will take a look at how this could be done here, using IEP.
- The soldiers receive the order to launch the missile
- Key A, Key B and the fire button have to be pressed at the same time (within a span of 1 second).
- As a consequence, a file is written with the fire order.
- This could also be used as a mean to detect conflicting events that should not happen at the same time, or that should respect black out periods.
Design
- We need capture the inbound stream, and keep the events that just occurred in the last second.
- For simplicity's sake, we will consider that only one event of each type can happen at any single second.
- When the events are captured, we will do a union in the key streams, and if we have more than 1 key, we will trigger that the security criteria has been observed.
- With the security criteria and the fire button pressed, we will send the order message to launch the missile.
IEP Constructs Used
Process Flow
//
NOTES:
- The inbound streams are routed through a time based window of 1 second.
- The security check is in green
- All blue boxes are not necessary for the process to work. But they do provide valuable debugging information.
- The authorized fire is a check that
- the count(turnedkey)>=2 and that the fire=1
- We only take new authorization to be placed in the output stream
Example Limitations
- This is a exercise only....
- The first run may not work, as the service assembly needs to be loaded, the 1 second criteria may not be met.
- Run it a second time.
- If it still doesn't work, you may need to increase the time window, rebuild and redeploy.
- To test it, you will need to use the test at the project level. Running the tests one at a time, is just not fast enough, and will never trigger the outbound event (unless your name is lucky luke...)