Workers execute SIMPLE tasks that Conductor schedules. Start with the maintained Hello World: it registers greet, starts a Java worker, executes a workflow, and waits for completion.
For every SIMPLE task:
- The workflow task
name, task definition name, and worker task name must match exactly. - At least one live worker must poll that task name.
- The worker must be idempotent because Conductor may redeliver after a timeout or retry.
This is the most direct pattern and is used by Hello World:
import com.netflix.conductor.client.worker.Worker;
import com.netflix.conductor.common.metadata.tasks.Task;
import com.netflix.conductor.common.metadata.tasks.TaskResult;
public final class GreetWorker implements Worker {
@Override
public String getTaskDefName() {
return "greet";
}
@Override
public TaskResult execute(Task task) {
String name = (String) task.getInputData().getOrDefault("name", "World");
TaskResult result = new TaskResult(task);
result.setStatus(TaskResult.Status.COMPLETED);
result.getOutputData().put("greeting", "Hello, " + name + "!");
return result;
}
}Run workers with TaskRunnerConfigurer:
import java.util.List;
import com.netflix.conductor.client.automator.TaskRunnerConfigurer;
TaskRunnerConfigurer workers = new TaskRunnerConfigurer.Builder(taskClient, List.of(new GreetWorker()))
.withThreadCount(1)
.build();
workers.init();Call workers.shutdown() during application shutdown.
For method binding, use @WorkerTask, @InputParam, and @OutputParam:
import com.netflix.conductor.sdk.workflow.task.InputParam;
import com.netflix.conductor.sdk.workflow.task.OutputParam;
import com.netflix.conductor.sdk.workflow.task.WorkerTask;
public final class GreetingTasks {
@WorkerTask("greet")
public @OutputParam("greeting") String greet(@InputParam("name") String name) {
return "Hello, " + name + "!";
}
}WorkflowExecutor can discover public annotated methods from packages, classes, or existing instances. Existing instances preserve constructor injection:
import java.util.List;
import com.netflix.conductor.sdk.workflow.executor.WorkflowExecutor;
WorkflowExecutor executor = new WorkflowExecutor("http://localhost:8080/api");
executor.initWorkersFromInstances(List.of(new GreetingTasks()));See the current WorkflowExecutor source for all worker-loading options.
- Set task-definition retry and timeout policy deliberately; a worker timeout is not a business timeout.
- Keep workers stateless and make side effects idempotent with a request key or durable application record.
- Use task domains and independent worker deployments when different queues need isolation.
- Return
FAILED_WITH_TERMINAL_ERRORonly for non-retryable failures; let transient failures use the configured retry policy.
For a local-server workflow test, continue with the test harness.