Apama 10.11.3 | Developing Apama Applications | Developing Apama Applications in EPL | Common EPL Patterns in Monitors | Inline request-response pattern | Canonical form for synchronous requests
 
Canonical form for synchronous requests
The next example show the canonical form for when you want to code a pattern that specifies two or more synchronous requests.
The events:
event RequestA { integer requestId; ... }
event ResponseA { integer requestId; ... }
event RequestB { integer requestId; ... }
event ResponseB { integer requestId; ... }
The monitor:
monitor Client {
   action doWork() {
      //do some processing
      integer requestId := integer.getUnique();
      route RequestA(requestId,...);
      on ResponseA(id=requestId) as ra doWork2(ra);
   }
   action doWork2(ResponseA ra) {
      //do some more processing
      integer requestId := integer.getUnique();
      route RequestB(requestId,...);
      on ResponseB(id=requestId) as rb doWork3(rb);
   }
   action doWork3(ResponseB rb) {
      //do yet more processing
   }
}