-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[enhancement]adding ParallelExternalTaskResultUtil for synchronization
- Loading branch information
1 parent
2e81ed8
commit 0e02445
Showing
6 changed files
with
104 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...er/src/main/java/com/tosan/camunda/camundaclient/util/ParallelExternalTaskResultUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.tosan.camunda.camundaclient.util; | ||
|
||
import com.tosan.camunda.api.ExceptionIncidentState; | ||
import com.tosan.camunda.camundaclient.config.RetryConfig; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.camunda.bpm.client.task.ExternalTask; | ||
import org.camunda.bpm.client.task.ExternalTaskService; | ||
|
||
/** | ||
* @author Shahryar Safizadeh | ||
* @since 12/5/2023 | ||
*/ | ||
@Slf4j | ||
public class ParallelExternalTaskResultUtil extends ExternalTaskResultUtil { | ||
|
||
public ParallelExternalTaskResultUtil(RetryConfig retryConfig) { | ||
super(retryConfig); | ||
} | ||
|
||
@Override | ||
public void declareTaskCompleted(Object[] args) { | ||
ExternalTask externalTask = getExternalTask(args); | ||
String businessKey = externalTask.getBusinessKey().intern(); | ||
log.info("Acquiring lock for business key:{}", businessKey); | ||
synchronized (businessKey) { | ||
log.debug("Lock has been acquired by task with business key: {}", businessKey); | ||
super.declareTaskCompleted(args); | ||
} | ||
log.info("Lock has been released from task with business key: {}", businessKey); | ||
} | ||
|
||
@Override | ||
public void handleBpmnException(ExternalTask externalTask, ExternalTaskService externalTaskService, String errorCode, String errorMessage) { | ||
String businessKey = externalTask.getBusinessKey().intern(); | ||
log.info("Acquiring lock for business key:{}", businessKey); | ||
synchronized (businessKey) { | ||
log.debug("Lock has been acquired by task with business key: {}", businessKey); | ||
super.handleBpmnException(externalTask, externalTaskService, errorCode, errorMessage); | ||
} | ||
log.info("Lock has been released from task with business key: {}", businessKey); | ||
} | ||
|
||
@Override | ||
public void handleException(ExceptionIncidentState exceptionIncidentState, Exception e, Object[] args, boolean convertToBpmnError) { | ||
ExternalTask externalTask = getExternalTask(args); | ||
String businessKey = externalTask.getBusinessKey().intern(); | ||
log.info("Acquiring lock for business key:{}", businessKey); | ||
synchronized (businessKey) { | ||
log.debug("Lock has been acquired by task with business key: {}", businessKey); | ||
super.handleException(exceptionIncidentState, e, args, convertToBpmnError); | ||
} | ||
log.info("Lock has been released from task with business key: {}", businessKey); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters