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
BedrockMission!

Learn More

View all

Sign in to view all badges

Stop retrying Workflow using java

Avatar

Avatar
Validate 1
Level 1
infinityskyline
Level 1

Like

1 like

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
infinityskyline
Level 1

Like

1 like

Total Posts

15 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
infinityskyline
Level 1

16-04-2021

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.

AEM java workflow

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

190 likes

Total Posts

239 posts

Correct Reply

74 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

190 likes

Total Posts

239 posts

Correct Reply

74 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile
Ravi_Pampana
MVP

16-04-2021

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);

Answers (1)

Answers (1)

Avatar

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

560 likes

Total Posts

677 posts

Correct Reply

194 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile

Avatar
Give Back 100
Level 10
asutosh_jena
Level 10

Likes

560 likes

Total Posts

677 posts

Correct Reply

194 solutions
Top badges earned
Give Back 100
Boost 500
Affirm 100
Ignite 1
Establish
View profile
asutosh_jena
Level 10

16-04-2021

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!