I am running a workflow in java sdk. I have registered exception type in FailWorkflowExceptionTypes of the worker. When there is exception, it doesn’t fail the workflow and retries it until the max attempts.
Simplified code that simulate the behavior is below,
public class HelloTest {
static final String TASK_QUEUE = "mytaskqueue";
static final String WORKFLOW_ID = "HelloExceptionWorkflow";
@WorkflowInterface
public interface MyWorkflow {
@WorkflowMethod
String workflowMethod(String greeting, String name);
}
@ActivityInterface
public interface MyActivity {
String activityMethod(String greeting, String name);
}
public static class MyWorkflowChildImpl implements MyWorkflow {
private final MyActivity activities =
Workflow.newActivityStub(
MyActivity.class,
ActivityOptions.newBuilder()
.setStartToCloseTimeout(Duration.ofMinutes(1))
.setScheduleToStartTimeout(Duration.ofSeconds(5))
.setRetryOptions(
RetryOptions.newBuilder()
.setInitialInterval(Duration.ofSeconds(1))
.setMaximumAttempts(5)
.build())
.build());
@Override
public String workflowMethod(String greeting, String name) {
return activities.activityMethod(greeting, name);
}
}
static class MyActivityImpl implements MyActivity {
public String activityMethod(String greeting, String name) {
throw new IllegalStateException("this is intentional");
}
}
public static void main(String[] args) {
// Define the workflow service.
WorkflowServiceStubs service = WorkflowServiceStubs.newLocalServiceStubs();
WorkflowClient client = WorkflowClient.newInstance(service);
WorkerFactory factory = WorkerFactory.newInstance(client);
Worker worker = factory.newWorker(TASK_QUEUE);
WorkflowImplementationOptions options =
WorkflowImplementationOptions.newBuilder()
.setFailWorkflowExceptionTypes(IllegalStateException.class)
.build();
worker.registerWorkflowImplementationTypes(options, MyWorkflowChildImpl.class);
worker.registerActivitiesImplementations(new MyActivityImpl());
factory.start();
WorkflowOptions workflowOptions =
WorkflowOptions.newBuilder().setWorkflowId(WORKFLOW_ID).setTaskQueue(TASK_QUEUE).build();
MyWorkflow myWorkflow = client.newWorkflowStub(MyWorkflow.class, workflowOptions);
myWorkflow.workflowMethod("hello", "test");
}
}
Is this a bug, or am I missing something here?