aws / aws-swf-flow-library

AWS Simple Workflow Flow framework library
Apache License 2.0
61 stars 54 forks source link

@ExponentialRetry is not working #45

Open agghimanshu opened 2 years ago

agghimanshu commented 2 years ago

https://docs.aws.amazon.com/amazonswf/latest/awsflowguide/features-retry.html

After following above document for ExponentialRetry, our activities are not retrying automatically as mentioned in the document. Is there any other thing needed apart from adding @ExponentialRetry on the Activity method.

Below is my Sample code-----

@Activities @ActivityRegistrationOptions(defaultTaskScheduleToStartTimeoutSeconds = 30, defaultTaskStartToCloseTimeoutSeconds = 30) public interface IMyActivities {

@Activity(name = "PrintHello", version = "24.0")
@ExponentialRetry(
        initialRetryIntervalSeconds = 1,
        exceptionsToRetry = IllegalStateException.class,
        maximumAttempts = 5)
String printHello();

@Activity(name = "PrintBye", version = "18.0")
void printBye(String x);

}

@Workflow @WorkflowRegistrationOptions(defaultExecutionStartToCloseTimeoutSeconds = 60, defaultTaskStartToCloseTimeoutSeconds = 30) public interface IWorkflow {

@Execute(name = "DemoWorkflow", version = "11.0")
void start();

@GetState
String getState();

}

@Component @Setter public class WorkflowServiceImpl implements IWorkflow { private String state = "Started";

IMyActivitiesClientImpl client = new IMyActivitiesClientImpl();

@Override
public void start() {
    System.out.println("before calling");
    this.handleActivity();
    System.out.println("after calling");
}

@Override
public String getState() {
    System.out.println("state-----" +state);
    return state;
}

private void handleActivity(){
    Promise<String> result = client.printHello();
    client.printBye(result);
}

}

public class MyActivitiesImpl implements IMyActivities {

private boolean check = true;

@Override
public String printHello() {
    System.out.println("In activity 1111");
    if (check) {
        check = false;
        System.out.println("121212121");
       throw new IllegalStateException("showing this for the first time from this activity");
    }
    return "Hello World";
}

@Override
public void printBye(String name) {
    System.out.println("In activity 2222  " + name);
}

}