@@ -270,12 +270,28 @@ private void executeWorkflowAsync(
270
270
ActionListener <WorkflowResponse > listener
271
271
) {
272
272
try {
273
- threadPool .executor (PROVISION_WORKFLOW_THREAD_POOL ).execute (() -> { executeWorkflow (template , workflowSequence , workflowId ); });
273
+ threadPool .executor (PROVISION_WORKFLOW_THREAD_POOL ).execute (() -> {
274
+ updateTemplate (template , workflowId );
275
+ executeWorkflow (template , workflowSequence , workflowId );
276
+ });
274
277
} catch (Exception exception ) {
275
278
listener .onFailure (new FlowFrameworkException ("Failed to execute workflow " + workflowId , ExceptionsHelper .status (exception )));
276
279
}
277
280
}
278
281
282
+ /**
283
+ * Replace template document
284
+ * @param template The template to store after reprovisioning completes successfully
285
+ * @param workflowId The workflowId associated with the workflow that is executing
286
+ */
287
+ private void updateTemplate (Template template , String workflowId ) {
288
+ flowFrameworkIndicesHandler .updateTemplateInGlobalContext (workflowId , template , ActionListener .wrap (templateResponse -> {
289
+ logger .info ("Updated template for {}" , workflowId );
290
+ }, exception -> { logger .error ("Failed to update use case template for {}" , workflowId , exception ); }),
291
+ true // ignores NOT_STARTED state if request is to reprovision
292
+ );
293
+ }
294
+
279
295
/**
280
296
* Executes the given workflow sequence
281
297
* @param template The template to store after reprovisioning completes successfully
@@ -289,8 +305,9 @@ private void executeWorkflow(Template template, List<ProcessNode> workflowSequen
289
305
for (ProcessNode processNode : workflowSequence ) {
290
306
List <ProcessNode > predecessors = processNode .predecessors ();
291
307
logger .info (
292
- "Queueing process [{}].{}" ,
308
+ "Queueing Process [{} (type: {}) ].{}" ,
293
309
processNode .id (),
310
+ processNode .workflowStep ().getName (),
294
311
predecessors .isEmpty ()
295
312
? " Can start immediately!"
296
313
: String .format (
@@ -321,18 +338,6 @@ private void executeWorkflow(Template template, List<ProcessNode> workflowSequen
321
338
322
339
logger .info ("updated workflow {} state to {}" , workflowId , State .COMPLETED );
323
340
324
- // Replace template document
325
- flowFrameworkIndicesHandler .updateTemplateInGlobalContext (
326
- workflowId ,
327
- template ,
328
- ActionListener .wrap (templateResponse -> {
329
- logger .info ("Updated template for {}" , workflowId , State .COMPLETED );
330
- }, exception -> {
331
- String errorMessage = "Failed to update use case template for " + workflowId ;
332
- logger .error (errorMessage , exception );
333
- }),
334
- true // ignores NOT_STARTED state if request is to reprovision
335
- );
336
341
}, exception -> { logger .error ("Failed to update workflow state for workflow {}" , workflowId , exception ); })
337
342
);
338
343
} catch (Exception ex ) {
0 commit comments