Skip to content

Commit

Permalink
avoid exception stack trace in startup when default maintenance workf…
Browse files Browse the repository at this point in the history
…low already exists
  • Loading branch information
Edvard Fonsell committed Apr 6, 2020
1 parent 77265a4 commit be52712
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.nflow.engine.service.MaintenanceConfiguration;
import io.nflow.engine.service.MaintenanceConfiguration.ConfigurationItem;
import io.nflow.engine.service.WorkflowInstanceService;
import io.nflow.engine.workflow.instance.QueryWorkflowInstances;
import io.nflow.engine.workflow.instance.WorkflowInstanceFactory;

@Component
Expand Down Expand Up @@ -53,12 +54,16 @@ private void apply(Environment env, String property, Supplier<ConfigurationItem.
public void start() {
if (insertOnStartup) {
insertOnStartup = false;
instanceService.insertWorkflowInstance(workflowInstanceFactory.newWorkflowInstanceBuilder() //
.setType(MAINTENANCE_WORKFLOW_TYPE) //
.putStateVariable(VAR_SCHEDULE, initialCronSchedule) //
.putStateVariable(VAR_MAINTENANCE_CONFIGURATION, initialConfiguration) //
.setExternalId(MAINTENANCE_WORKFLOW_DEFAULT_EXTERNAL_ID) //
.build());
QueryWorkflowInstances query = new QueryWorkflowInstances.Builder().addTypes(MAINTENANCE_WORKFLOW_TYPE)
.setExternalId(MAINTENANCE_WORKFLOW_DEFAULT_EXTERNAL_ID).build();
if (instanceService.listWorkflowInstances(query).isEmpty()) {
instanceService.insertWorkflowInstance(workflowInstanceFactory.newWorkflowInstanceBuilder() //
.setType(MAINTENANCE_WORKFLOW_TYPE) //
.putStateVariable(VAR_SCHEDULE, initialCronSchedule) //
.putStateVariable(VAR_MAINTENANCE_CONFIGURATION, initialConfiguration) //
.setExternalId(MAINTENANCE_WORKFLOW_DEFAULT_EXTERNAL_ID) //
.build());
}
}
}
}

0 comments on commit be52712

Please sign in to comment.