The asynchronous model is designed for advice implementations that take some time to execute. These are usually advice implementations that communicate with external systems, perform input/output operations or perform tasks that can potentially bring down the performance of a ActiveMatrix BusinessWorks application.An asynchronous advice implementation does not execute its business logic on the engine job thread. In other words, the ActiveMatrix BusinessWorks engine does not hold the job thread until an asynchronous advice completes its execution. This allows the engine to execute advices and/or activities that might exist in the process on parallel tracks, while the asynchronous advice is executing. The engine does not, however, continue executing the next advice in the join point, or the next activity on the same track before the asynchronous advice completes its execution.A typical asynchronous advice implementation gets a thread from a thread pool in its execute() method and starts executing its business logic on it. Right after that it calls AdviceController->setPending() with the appropriate timeout and returns from its execute(). After its business logic completes and before the advice thread finishes executing, the advice implementation calls AdviceController->setReady() with the result object. Once the job thread is available to finish executing the asynchronous advice, the engine calls its postExecute()method by passing the result object received in the setReady()call. The advice implementation gets the opportunity to do any final job related cleanup operations before returning the final result object back to the engine.If the advice implementation does not complete its execution in the allotted time, which is specified in the setPending() call, the engine times out the advice implementation by calling its cancelled() method. An advice implementation that does not communicate with external systems, does not perform input/output operations and tasks that may take some time to execute can be implemented as synchronous advice implementation.
Copyright © TIBCO Software Inc. All Rights Reserved.