Skip to content

adds an API to terminate workflows by correlationId#52

Open
rksinha wants to merge 3 commits into
masterfrom
terminate_by_correlationid
Open

adds an API to terminate workflows by correlationId#52
rksinha wants to merge 3 commits into
masterfrom
terminate_by_correlationid

Conversation

@rksinha
Copy link
Copy Markdown

@rksinha rksinha commented Jan 3, 2020

Adds a support to terminate workflows by correlation id.


List<Workflow> workflows = executionDAOFacade.getWorkflowsByCorrelationId(correlationId, includeTasks);
List<Workflow> result = new LinkedList<>();
for (Workflow wf : workflows) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use java8 stream construct here.

Copy link
Copy Markdown
Author

@rksinha rksinha Jan 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure we can, i kept it consistent with the Code already written in other counter Method.

`
public List getWorkflowInstances(String workflowName, String correlationId, boolean includeClosed, boolean includeTasks) {

	List<Workflow> workflows = executionDAOFacade.getWorkflowsByCorrelationId(correlationId, includeTasks);
	List<Workflow> result = new LinkedList<>();
	for (Workflow wf : workflows) {
		if (wf.getWorkflowName().equals(workflowName) && (includeClosed || wf.getStatus().equals(Workflow.WorkflowStatus.RUNNING))) {
			result.add(wf);
		}
	}

	return result;
}`

public void terminateWorkflowByCorrelationId(String correlationId, String reason) {
List<Workflow> workflows = executionService.getWorkflowInstancesByCorrelationId(correlationId, false);
workflows.parallelStream().forEach( workflow ->
workflowExecutor.terminateWorkflow(workflow.getWorkflowId(), reason)
Copy link
Copy Markdown

@manan164 manan164 Jan 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to put info log here for the workflow that is going to be terminated from this path.

Copy link
Copy Markdown

@manan164 manan164 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants