Wait time to trigger workflow
Hi,
I'm using a listener class to trigger a workflow on modification assets based on asset type. Since multiple assets are uploaded at once updating the properties in assets is giving persistence exception. I have configured a job queue for our model. It is triggering the workflow in order but not sure whether it's waiting for the previous wf to complete and then start. How to check whether the previous wf is completed and then trigger the wf for next asset.
private void triggerWorkflow(ResourceResolver resourceResolver, String resourcePath) {
try {
WorkflowSession workflowSession = resourceResolver.adaptTo(WorkflowSession.class);
if (workflowSession != null) {
WorkflowModel workflowModel = workflowSession.getModel(SamsConstants.MEDIA_SET_WF_MODEL);
if (workflowModel == null) {
log.error("Workflow model not found: {}", SamsConstants.MEDIA_SET_WF_MODEL);
return;
}
WorkflowData workflowData = workflowSession.newWorkflowData("JCR_PATH", resourcePath);
workflowSession.startWorkflow(workflowModel, workflowData);
} else {
log.error("Workflow session is null.");
}
} catch (Exception e) {
log.error("Error triggering workflow for resource at {}", resourcePath, e);
}
This is the piece of code where I'm calling the wf. Please let me know the better approach I can follow.
Thank You.
