Skip to content

Commit

Permalink
Move away from thread?
Browse files Browse the repository at this point in the history
  • Loading branch information
wcgunter committed Feb 16, 2024
1 parent abb2a46 commit cdc5cf3
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions cws-tasks/src/main/java/jpl/cws/task/CwsTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
Expand All @@ -11,7 +12,6 @@

import jpl.cws.core.service.ProcessService;
import jpl.cws.core.service.SpringApplicationContext;
import org.springframework.beans.factory.annotation.Autowired;

/**
* Abstract base class for all CWS built-in (and custom user-added) task
Expand All @@ -20,8 +20,6 @@
*/
public abstract class CwsTask implements JavaDelegate {

@Autowired private ProcessService cwsProcessService;

public static final String UNEXPECTED_ERROR = "unexpectedError";

protected final CwsTaskLogger log = new CwsTaskLogger(this.getClass().getName());
Expand Down Expand Up @@ -116,19 +114,16 @@ public void execute(final DelegateExecution execution) {

private void notifyWorkerOfFailedProcess() {
log.debug("notifying workers of failed process...");
(new Thread() {
public void run() {
try {
// This delay is necessary, because the process must actually
// complete in Camunda before we can look at Camunda's records
// to get the true status of the process instance.
sleep(1000);
cwsProcessService.sendProcEventTopicMessageWithRetries(null, null, null, null, "sync");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
try {
// This delay is necessary, because the process must actually
// complete in Camunda before we can look at Camunda's records
// to get the true status of the process instance.
TimeUnit.SECONDS.sleep(2);
ProcessService cwsProcessService = (ProcessService) SpringApplicationContext.getBean("cwsProcessService");
cwsProcessService.sendProcEventTopicMessageWithRetries(null, null, null, null, "sync");
} catch (InterruptedException e) {
e.printStackTrace();
}
}


Expand Down

0 comments on commit cdc5cf3

Please sign in to comment.