Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Stop retrying Workflow using java

infinityskyline
Level 2
Level 2

Hi,

I have a custom workflow which I don't want to be retried if fails.

if (schemaErrors.size() > 0) {

                // session.terminateWorkflow(item.getWorkflow());

                String message = LOG.log(Messages.EXCEPTION_RUNNING_UPGRADE_WORKFLOW);

                throw new WorkflowException(message);

}

Is there a way to stop retrying once I throw a workflow exception? I have tried with terminateWorkflow but it doesn't seem to work.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution
Ravi_Pampana
Correct answer by
Community Advisor
Community Advisor

Hi,

 

If you throw WorkflowException then WF engine will retry the workflow later based on the AEM workflow Engine configuration. If you remove throwing the exception then retry should not occur.

 

throw new WorkflowException("Unable to complete processing the Workflow Process step", e);

View solution in original post

2 Replies
Asutosh_Jena_
Community Advisor
Community Advisor

Hi @infinityskyline 

 

Within the execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) you can write the below step which will terminate the workflow.

 

Workflow workflow = workflowSession.getWorkflow(workItem.getWorkflow().getId());
workflowSession.terminateWorkflow(workflow);

 

Thanks! 

Ravi_Pampana
Correct answer by
Community Advisor
Community Advisor

Hi,

 

If you throw WorkflowException then WF engine will retry the workflow later based on the AEM workflow Engine configuration. If you remove throwing the exception then retry should not occur.

 

throw new WorkflowException("Unable to complete processing the Workflow Process step", e);

View solution in original post