You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Camunda workflows will no longer be invoked when new student_assessment records are created. Triggering a workflow will be a responsibility of a new scheduler.
All the student_assessment records will be associated with the application's current assessment alongside its creation, which means that the current assessment will always point to the most recent assessment record.
Multiple student_assessment records can be created and all will be executed in the creation order.
The student_assessment records for the same application should be executed in order, but different applications for the same students can be executed in parallel.
Two new schedulers will be created.
Assessment workflow execution (every few seconds): used to start and cancel workflows.
Assessment workflow execution retry (every few hours): used to retry start and cancelation operations that are taking too long.
Two existing queues will be still used.
start-application-assessment
cancel-application-assessment
New status will be created for the student_assessment table to allow its control by the schedulers.
Add also an extra column, similar to sims.applications.application_status_updated_on to track the date that the status was updated (e.g. student_assessment_status_updated_on).
Add a new column current_processing_assessment_id to the sims.applications to be updated by the scheduler. Every time that a record is queued for execution this new column will also be updated.
Student Application cancellation will happen only before the application is in "Completed" status. Right now there is no scenario where a completed application or an application with reassessment records would be canceled.
New status for the assessment
Created: when the student_assessment is created.
Set by the code creating the record. Can be the default value for the new column.
Queued: when the student_assessment is queued to be executed on Camunda. Change the status to Queued and call the queue after, in this way, if the Camunda call fails it will retry later because the status is already set.
Set by the new scheduler: Assessment workflow execution.
In progress: when the workflow id is associated with the student_assessment.
Se from a Camunda worker (e.g. associate-workflow-instance-task).
Completed: at the end by a dedicated worker.
Set by a new Camunda worker to be created.
Cancellation requested: when a workflow needs to be canceled, for instance, when the student cancels the application or the "Bulk offering update" happens and the application is in progress. The student_assessment can have the status updated to Cancellation requested to be selected by the specific queue and then have its status finally updated to Cancelled.
Set by the application code requesting the cancellation.
Cancellation queued: create a new item in the queue cancel-application-assessment. This queue should also be changed to update the student_assessment to Cancelled.
Set by the new scheduler Assessment workflow execution.
Cancelled: when the workflow is canceled or a call to Camunda to cancel the workflow returns a "Not found".
Set by the existing queue cancel-application-assessment.
Regular Assessment Lifecycle
For a single workflow execution, the assessments will progress as shown below.
Stage 1
The student_assessment record is saved to the database with the default Created status.
Stage 2
The record with Created status:
is selected by the assessment-workflow-execution-queue scheduler.
its status is updated to Queued.
Its id is also set in the application's current_processing_assessment_id column.
it is added to the start-application-assessment queue.
Stage 3
The workflow has its execution started by Camunda.
The associate-workflow-instance worker, besides setting the workflow_id in DB (already happening), also sets the workflow status to In progress.
During this stage, alongside the associate-workflow-instance execution, if another workflow was already set to process the student_assessment, use the job.cancelWorkflow(); to terminate its execution.
Stage 4
A new workflow worker is created at the end of the workflow to have the student_assessment record changed to completed.
Queued Assessment Lifecycle
On the occasion when more than one student_assessment record is created, a scheduler will coordinate their ordered execution.
At any given time, assessments for one particular application can have 0 to 1 "Queued" records and 1 to n created records waiting to be processed.
Every time that a student_assessment record is queued its id is also set in the application's current_processing_assessment_id column.
The cancellation of a workflow is currently executed by the queue cancel-application-assessment. The Offering bulk change, for instance, executes also the bulk cancellation of any In progress application.
To allow the cancellation to also be handled by the schedulers, we can use the assessment status Cancellation requested to update any student-assessment to be canceled. The scheduler can then look for these records and try to execute the process and set the student-assessment as canceled.
The workflow cancellation process happens immediately and right now it is processed by cancel-application-assessment.processor.ts. Student Application cancellation will happen only before the application is in "Completed" status. Right now there is no scenario where a completed application or an application with reassessment records would be canceled.
Coordinate the execution of all the student_assessments to ensure its execution. Allow multiple student_assessments to be created and ensures their ordered execution and its association with the application's current assessment.
Execution interval
Executed every minute or some short interval to be discussed.
Target records
Any application where the current assessment is in Created status.
Any application where the current assessment is in Completed status and there is 1 to n Created assessment (waiting to be executed). Only the oldest assessment record in Created status will be selected for each application.
Process description
If the current assessment is in Created status.
1 - Change the status to Queued.
2 - Queue the assessment for execution (already existing start-application-assessment).
If the current assessment is NOT in Created status.
1 - Change the status to Queued.
2 - Update the application's current assessment to point to this record.
3 - Queue the assessment for execution (already existing start-application-assessment).
Checks for any stalled Queuedstudent_assessments that did not start after a long period.
Execution interval
Executed every few hours or some long interval to be discussed.
Target records
Any application where the current assessment is in Queued status for some long period of time (e.g. 6 hours).
Process description
Queue the assessment for execution (already existing start-application-assessment).
Refactors
Schedulers should trigger workflows
Stop triggering the start-application-assessment and the cancel-application-assessment from the applications. Only the new schedulers would be responsible for triggering the Camunda workflows and canceling them. We can consider maybe letting the "Original Assessment" trigger the assessment for a better user experience once the application is submitted.
Current points triggering the assessment workflow:
Some assessment creations, like Scholastic Standing, also create notifications for the students. We should consider triggering these notifications when the specific assessment becomes the application's current assessment.
Other refactors
Check if the code current inside method startAssessment can be moved to the start-application-assessment queue.
Summary of the technical work done so far for this epic (#1896, #2179, #2183, #2180).
Workflows are no longer initiated as soon as they are created. For instance, submitting a Student application can take up to 30s to start the process.
Applications (even from the same student) can have assessments processed at the same time (in parallel). A single application will have only one assessment being processed at a single time, which means, if two assessments are pending for the same application, the oldest will be processed and, once this is done, the next one will start.
Any batch operation that can potentially create multiple assessments is now supported, like the below ones.
Assessments can now be approved while the same application has already been with one assessment in progress. Before if the Ministry tried to approve one assessment while the other was in progress it would generate an issue.
Better error handling when the same assessment is started twice. Before an incident was generated in Camunda. Now the system can smart detect it and cancel the second incorrect instance.
student_assessment
records are created. Triggering a workflow will be a responsibility of a new scheduler.student_assessment
records will be associated with the application's current assessment alongside its creation, which means that the current assessment will always point to the most recent assessment record.student_assessment
records can be created and all will be executed in the creation order.student_assessment
records for the same application should be executed in order, but different applications for the same students can be executed in parallel.start-application-assessment
cancel-application-assessment
student_assessment
table to allow its control by the schedulers.sims.applications.application_status_updated_on
to track the date that the status was updated (e.g.student_assessment_status_updated_on
).current_processing_assessment_id
to thesims.applications
to be updated by the scheduler. Every time that a record is queued for execution this new column will also be updated.New status for the assessment
Created
: when the student_assessment is created.Queued
: when the student_assessment is queued to be executed on Camunda. Change the status toQueued
and call the queue after, in this way, if the Camunda call fails it will retry later because the status is already set.Assessment workflow execution
.In progress
: when the workflow id is associated with the student_assessment.associate-workflow-instance-task
).Completed
: at the end by a dedicated worker.Cancellation requested
: when a workflow needs to be canceled, for instance, when the student cancels the application or the "Bulk offering update" happens and the application is in progress. The student_assessment can have the status updated toCancellation requested
to be selected by the specific queue and then have its status finally updated toCancelled
.Cancellation queued
: create a new item in the queuecancel-application-assessment
. This queue should also be changed to update thestudent_assessment
toCancelled
.Assessment workflow execution
.Cancelled
: when the workflow is canceled or a call to Camunda to cancel the workflow returns a "Not found".cancel-application-assessment
.Regular Assessment Lifecycle
For a single workflow execution, the assessments will progress as shown below.
Stage 1
The student_assessment record is saved to the database with the default
Created
status.Stage 2
The record with
Created
status:assessment-workflow-execution-queue
scheduler.Queued
.current_processing_assessment_id
column.start-application-assessment
queue.Stage 3
associate-workflow-instance
worker, besides setting the workflow_id in DB (already happening), also sets the workflow status toIn progress
.During this stage, alongside the
associate-workflow-instance
execution, if another workflow was already set to process thestudent_assessment
, use thejob.cancelWorkflow();
to terminate its execution.Stage 4
A new workflow worker is created at the end of the workflow to have the
student_assessment
record changed to completed.Queued Assessment Lifecycle
On the occasion when more than one
student_assessment
record is created, a scheduler will coordinate their ordered execution.At any given time, assessments for one particular application can have 0 to 1 "Queued" records and 1 to n created records waiting to be processed.
Every time that a
student_assessment
record is queued its id is also set in the application'scurrent_processing_assessment_id
column.Stage 1
Private Zenhub Image
Stage 2
Stage 3
Assessment Cancellation Lifecycle
The cancellation of a workflow is currently executed by the queue
cancel-application-assessment
. The Offering bulk change, for instance, executes also the bulk cancellation of anyIn progress
application.To allow the cancellation to also be handled by the schedulers, we can use the assessment status
Cancellation requested
to update anystudent-assessment
to be canceled. The scheduler can then look for these records and try to execute the process and set thestudent-assessment
as canceled.The workflow cancellation process happens immediately and right now it is processed by cancel-application-assessment.processor.ts.
Student Application cancellation will happen only before the application is in "Completed" status. Right now there is no scenario where a completed application or an application with reassessment records would be canceled.
Schedulers
Assessment workflow execution (
assessment-workflow-execution-queue
)Coordinate the execution of all the
student_assessments
to ensure its execution. Allow multiplestudent_assessments
to be created and ensures their ordered execution and its association with the application's current assessment.Execution interval
Executed every minute or some short interval to be discussed.
Target records
Created
status.Completed
status and there is 1 to nCreated
assessment (waiting to be executed). Only the oldest assessment record inCreated
status will be selected for each application.Process description
Created
status.1 - Change the status to
Queued
.2 - Queue the assessment for execution (already existing
start-application-assessment
).Created
status.1 - Change the status to
Queued
.2 - Update the application's current assessment to point to this record.
3 - Queue the assessment for execution (already existing
start-application-assessment
).Assessment Workflow execution retry (
assessment-workflow-execution-queue-retry
)Checks for any stalled
Queued
student_assessments
that did not start after a long period.Execution interval
Executed every few hours or some long interval to be discussed.
Target records
Any application where the current assessment is in
Queued
status for some long period of time (e.g. 6 hours).Process description
Queue the assessment for execution (already existing
start-application-assessment
).Refactors
Schedulers should trigger workflows
Stop triggering the
start-application-assessment
and thecancel-application-assessment
from the applications. Only the new schedulers would be responsible for triggering the Camunda workflows and canceling them. We can consider maybe letting the "Original Assessment" trigger the assessment for a better user experience once the application is submitted.Current points triggering the assessment workflow:
Current points for canceling the assessment workflow:
Notifications
Some assessment creations, like Scholastic Standing, also create notifications for the students. We should consider triggering these notifications when the specific assessment becomes the application's current assessment.
Other refactors
start-application-assessment
queue.The text was updated successfully, but these errors were encountered: