Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[incubator-kie-issues#1650] Add nodeInstanceId reference to node SLA timers #3799

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,10 @@ public void configureTimers() {
}

public TimerInstance configureSLATimer(String slaDueDateExpression) {
return configureSLATimer(slaDueDateExpression, null);
}

public TimerInstance configureSLATimer(String slaDueDateExpression, String nodeInstanceId) {
// setup SLA if provided
slaDueDateExpression = resolveVariable(slaDueDateExpression).toString();
if (slaDueDateExpression == null || slaDueDateExpression.trim().isEmpty()) {
Expand All @@ -583,7 +587,7 @@ public TimerInstance configureSLATimer(String slaDueDateExpression) {

TimerInstance timerInstance = createDurationTimer(duration);
if (useTimerSLATracking()) {
registerTimer(timerInstance);
registerTimer(timerInstance, nodeInstanceId);
}
return timerInstance;
}
Expand All @@ -598,13 +602,18 @@ private TimerInstance createDurationTimer(long duration) {
}

private TimerInstance registerTimer(TimerInstance timerInstance) {
return registerTimer(timerInstance, null);
}

private TimerInstance registerTimer(TimerInstance timerInstance, String nodeInstanceId) {
ProcessInstanceJobDescription description =
ProcessInstanceJobDescription.newProcessInstanceJobDescriptionBuilder()
.id(timerInstance.getId())
.timerId(timerInstance.getTimerId())
.expirationTime(DurationExpirationTime.after(timerInstance.getDelay()))
.processInstanceId(getStringId())
.processId(getProcessId())
.nodeInstanceId(nodeInstanceId)
.build();
JobsService jobsService = InternalProcessRuntime.asKogitoProcessRuntime(getKnowledgeRuntime().getProcessRuntime()).getJobsService();
jobsService.scheduleJob(description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void internalTrigger(final KogitoNodeInstance from, String type) {
protected void configureSla() {
String slaDueDateExpression = (String) getNode().getMetaData().get("customSLADueDate");
if (slaDueDateExpression != null) {
TimerInstance timer = ((WorkflowProcessInstanceImpl) getProcessInstance()).configureSLATimer(slaDueDateExpression);
TimerInstance timer = ((WorkflowProcessInstanceImpl) getProcessInstance()).configureSLATimer(slaDueDateExpression, this.getId());
if (timer != null) {
this.slaTimerId = timer.getId();
this.slaDueDate = new Date(System.currentTimeMillis() + timer.getDelay());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void internalTrigger(KogitoNodeInstance from, String type) {
protected void configureSla() {
String slaDueDateExpression = (String) getNode().getMetaData().get("customSLADueDate");
if (slaDueDateExpression != null) {
TimerInstance timer = ((WorkflowProcessInstanceImpl) getProcessInstance()).configureSLATimer(slaDueDateExpression);
TimerInstance timer = ((WorkflowProcessInstanceImpl) getProcessInstance()).configureSLATimer(slaDueDateExpression, this.getId());
if (timer != null) {
this.slaTimerId = timer.getId();
this.slaDueDate = new Date(System.currentTimeMillis() + timer.getDelay());
Expand Down
Loading