I'm always looking at ways to expand my use of PeopleCode and the PeopleSoft Application. Today my goal was to process multiple items concurrently using an Application Engine. My example would be to have 100k items to process via a CI. Instead of looping through each row and processing the CI I wanted to create 20 instances of the CI and run them concurrently.
I've not found a way to create an instance of say an Application Class/Package where I'm not required to wait for the return of a method before proceeding to the next instance. I'm using a java sleep function just to simulate the processing that needs to be done but hopefully you can see what I'd like to do. Any suggestions?
Application Engine
import AH_TEST:*; /** Initiate xNumber of instances **/ &maxInstance = 20; &testArray = CreateArray(""); For &i = 1 To &maxInstance &testArray.push(create AH_TEST:test(&i)); End-For; /** Watch until all are done processing **/ &allDone = False; While &allDone = False &allDone = True; For &i = 1 To &maxInstance If &testArray.isDone = False Then; &allDone = False; Break; End-If; End-For; End-While; Warning ("Done waiting for test to complete");
App Class
class test method test(&i As integer); method process(); property integer ID; property boolean isDone; end-class; method test /+ &i as Integer +/ &isDone = False; &ID = &i; Warning ("Starting #" | &i); GetJavaClass("java.lang.Thread").sleep(&i * 1000); %This.process(); end-method; method process Warning (&ID | " waited " | (&ID * 1000) | " seconds"); &isDone = True; end-method;
Try PSChrome the PeopleSoft Browser Extension