Gaetan Chaboussie created OFBIZ-13282:
-----------------------------------------

             Summary: JobTracker object
                 Key: OFBIZ-13282
                 URL: https://issues.apache.org/jira/browse/OFBIZ-13282
             Project: OFBiz
          Issue Type: Improvement
          Components: framework/service
    Affects Versions: Upcoming Branch
            Reporter: Gaetan Chaboussie


Hello community,
We recently got a client with an interesting need, and began reflecting on it 
(Nicolas and I).
The need is the following : be able to easily follow the advancement of a very 
large process.
For example, when an operator launches the generation of three thousands 
invoices, they want to be able to see how many have been treated, have an 
estimate on how long it would take, rerun the failed generations, how many 
failed so far, etc.

To this end, we started the development of what we called the JobTracker.
The idea is the following:
 * I launch the top service that plans all the unit generation jobs. This top 
service uses a dedicated engine (TrackedServiceEngine) that inits and injects a 
JobTracker object in the context.
 ** You can check the `testTrackedServiceAreTracked` unit test for an example 
implementation.
 * The JobTracker object has its corresponding persisting entity, that allows 
it to be retrieved from anywhere in the framework, associated with the 
JobTrackerFactory and its cache.
 * Each of the generating services is watched by the JobTracker object. At the 
end of each unit job, there is a check for the status of the whole list of 
tracked jobs to check completion.
 * When all the jobs have been run, the JobTracker status switches to complete.
 * Any time during the process of the list of unit jobs, the tracker can be 
accessed, and gathers all of the data of the jobs linked to it. It can (for 
example) give the completion percentage of the generation process.
 * At the end of each job, the result of the job can be stored in a dedicated 
new entity TrackedJobResult. This entity stores the Job final status, potential 
error messages, and can be extended for storing business related data, useful 
in a lot of ways. We didn’t use JobSandbox to store the result because they are 
automatically purged after some time.

If you want to test it for yourself, you can run the ‘ServiceForTestingTracker’ 
service that uses the description above.
You can then go to the view of the JobTrackers[1], and follow the real-time 
advancement of the tracker once it’s been selected.

[1] [https://localhost:8443/webtools/control/FindJobTracker]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to