๐Ÿ“œ Diagram for Lesson 5: Adding a Simple Activity

Visualizing Workflow-Activity Communication

Core architecture and communication flow between a workflow and its activities


Calculator Workflow Flow

flowchart TD A[Client starts CalculatorWorkflow] --> B[Workflow receives input: a, b, operation] B --> C{Workflow validates input} C -- Valid --> D[Call MathActivity.calculate] C -- Invalid --> E[Return error result] D --> F[Activity performs calculation] F --> G[Activity returns result] G --> H[Workflow receives result] H --> I[Workflow returns final result] subgraph "Worker Process" subgraph "Workflow Execution" B C H I end subgraph "Activity Execution" D F G end end style A fill:#e1f5fe style D fill:#f3e5f5 style F fill:#f3e5f5 style I fill:#e8f5e8

Architecture Separation

graph LR subgraph "Temporal Architecture" subgraph "Orchestration Layer" W[CalculatorWorkflow] W --> |"Coordinates"| O[Orchestration Logic] end subgraph "Execution Layer" A[MathActivity] A --> |"Executes"| B[Business Logic] end W -.->|"Calls via Stub"| A A -.->|"Returns Result"| W end style W fill:#e3f2fd style A fill:#f3e5f5 style O fill:#e8f5e8 style B fill:#fff3e0

๐Ÿ’ก Key Architecture Insights

Fundamental Pattern:

  • โœ… Workflows orchestrate - decision making and flow control
  • โœ… Activities execute - actual business logic and external calls
  • โœ… Clear separation between coordination and execution
  • โœ… Deterministic workflows call non-deterministic activities
  • โœ… Activity stubs provide type-safe communication

Benefits:

  • Testability - Each component can be tested independently
  • Scalability - Activities can scale based on workload
  • Reliability - Temporal handles retries and failures automatically

Communication Flow Details

Step-by-Step Execution:

  1. Client starts workflow with input parameters
  2. Workflow receives parameters and validates them
  3. Workflow creates activity stub and calls activity
  4. Activity performs actual calculation work
  5. Activity returns result to workflow
  6. Workflow processes result and returns to client

Key Concepts:

  • Synchronous calls from workflow perspective
  • Asynchronous execution under the hood
  • Automatic retry and timeout handling

๐Ÿš€ Production Benefits

This fundamental pattern provides:

  • โœ… Fault tolerance - Automatic retries and error handling
  • โœ… Scalability - Workers can be scaled independently
  • โœ… Observability - Complete execution history and logging
  • โœ… Maintainability - Clear separation of concerns
  • โœ… Testability - Components can be mocked and tested

Foundation for all complex Temporal workflows! ๐ŸŽ‰

results matching ""

    No results matching ""