Orchestrating Durable Workflows with Dapr and PubSub
These articles are AI-generated summaries. Please check the original sources for full details.
Dapr Workflows With PubSub
Dapr Workflows with PubSub enable durable orchestration of long-running processes. The system automatically resumes workflows after failures using persisted state, ensuring no data loss.
Why This Matters
Traditional approaches to workflow orchestration require manual state management, custom retry logic, and error handling scattered across services. These methods are error-prone and costly to maintain, with failures often leading to data loss or inconsistent states. Dapr Workflows eliminate this complexity by persisting state after each step and replaying workflows deterministically on resume. For example, a failed workflow restarts from the last persisted state, reducing manual intervention and ensuring resilience without sacrificing accuracy.
Key Insights
- “Automatic state persistence: Dapr workflows persist state after each step, ensuring resumption after failures.”
- “Deterministic code: Workflows must be deterministic as they are replayed on resume.”
- “Retry policies: Dapr applies retry policies automatically, managing timeouts and transient failures.”
Working Example
@Component
public class RideProcessingWorkflow implements Workflow {
@Override
public WorkflowStub create() {
return context -> {
WorkflowTaskOptions options = taskOptions();
context.getLogger().info("Step 1: Validating driver {}", request.getDriverId());
boolean isValid = context.callActivity(
ValidateDriverActivity.class.getName(), request, options, boolean.class)
.await();
if (!isValid) {
context.complete(new RideWorkflowStatus(
request.getRideId(), "FAILED", "Driver validation failed"));
return;
}
// Additional steps...
};
}
}
@Component
public class ValidateDriverActivity implements WorkflowActivity {
@Override
public Object run(WorkflowActivityContext context) {
RideWorkflowRequest request = context.getInput(RideWorkflowRequest.class);
if (request.getDriverId() != null && !request.getDriverId().isEmpty()) {
return true;
}
throw new IllegalArgumentException("Invalid driver ID");
}
}
Practical Applications
- Use Case: Ride-hailing system using Dapr Workflows to validate drivers, calculate fares, and notify passengers.
- Pitfall: Direct I/O operations in workflows cause non-determinism, leading to inconsistent replays after failures.
References:
Continue reading
Next article
Revisiting UI Components: Balancing Consistency and Accessibility in Solo Development
Related Content
LangGraph Architecture: When to Use Graph-Based Orchestration for AI Agents
Evaluate whether LangGraph's state management and human-in-the-loop features are necessary for your AI workflow or if simpler Python logic suffices.
Securing the Agentic Web: Leveraging Gemini Omni and Antigravity 2.0 for Multi-Agent Systems
Google I/O 2026 introduces Gemini Omni and Managed Agents API to enable secure, sandboxed execution for autonomous multi-agent workflows.
Gemma 4: Enabling Local-First Multimodal AI Infrastructure for Developers
Gemma 4 introduces a family of open models, including MoE and Dense variants, to enable high-reasoning multimodal workflows on local hardware.