Martini Synchronous vs Asynchronous Workflows - Understanding Workflow Patterns in Martini
Overview
Martini workflows follow two distinct patterns based on the nodes you use: synchronous workflows that execute continuously from start to finish, and asynchronous workflows that pause to wait for external events like scheduled times, events, etc. Understanding these patterns will help you understand and design solutions that match your real-world business processes, whether you're building instant-response APIs or multi-day workflows.
What You Will Learn
- What synchronous and asynchronous workflow patterns look like in Martini
- Real-world examples of what you can build with each pattern
- How to choose the right pattern for your use case
When To Use This
Use this guide when:
- You're designing a new workflow and want to understand execution patterns
Getting Started
New to Martini workflows? Start here:
- Choose your pattern based on your need:
- Building an API? → Start with Synchronous Workflow Pattern
-
Need to wait for responses which can take more than a few minutes to days? → Jump to Asynchronous Workflow Pattern
-
Follow the enterprise scenario that matches your use case
- Use the Pattern Recognition Guide to verify your approach
Time to complete: 15-30 minutes depending on complexity
Prerequisites
- Martini Designer installed and running
- Create a Martini Package
- Basic understanding of Workflow Designer
- Basic understanding of Data Mapping
- Familiarity with Martini workflow nodes
Synchronous Workflow Pattern
Workflows that execute continuously from start to finish without interruption. They process input data through each step sequentially until they complete their task or return a result.
Getting Started with Synchronous Workflows
Example of a synchronous workflow:
1 2 | |
Breaking down this example:
- Start Trigger Node - Receives the incoming request (API call, manual trigger)
- Map Node - Transforms input data into the format needed for database query
- Database Node - Executes database query to fetch or update data
- Map Node - Formats the final response with success status and updated data
Each node executes immediately after the previous one completes, with no waiting or pausing points.
Enterprise Scenario: Customer Data Update API
A CRM system needs to instantly update customer information and confirm the change:
1 2 | |
- Sales rep submits customer information update (Sends an API Request which triggers the workflow via the Start Trigger Node)
- System validates and formats customer ID and new information (Map Node)
- Updates customer record with new information in CRM database (Database Node)
- Creates success response with updated customer details and confirmation message (Map Node)
This synchronous pattern ensures that when customer information is updated, the change is processed immediately and the requesting system receives instant confirmation with the updated customer data.
When Synchronous Workflows Won't Work: Email Response Example
Consider this scenario where you need to send an email and wait for a reply:
1 2 3 | |
Why this fails:
- The email is sent instantly, but replies take time (minutes, hours, or days)
- The "Check for Reply" script runs immediately after sending, finding nothing
- Synchronous workflows can't pause and wait for external responses
- You'd need to implement complex polling or timeout logic
The solution: Use the Asynchronous Workflow Pattern instead:
1 2 3 | |
This demonstrates why choosing the right pattern matters - some business processes require waiting, which only asynchronous workflows can handle efficiently.
Synchronous Workflow Pattern Key Characteristics
| Characteristic | Description |
|---|---|
| Execution | Runs continuously from start to finish without interruption |
| Duration | Seconds to minutes |
| Resources | Holds execution thread and memory throughout |
| State | Kept in memory, no persistence needed |
| Best For | APIs, data transformations, instant responses |
How Synchronous Workflows Execute in Martini
When you start a synchronous workflow:
- Martini receives the trigger (Start Trigger Node, Email Trigger Node, Scheduler Trigger Node, Webhook Node, or other trigger types)
- Executes each node sequentially
- Returns result when complete
- Releases all resources immediately
Resource behavior: Execution thread stays active, memory held until completion, database connections maintained, all resources cleaned up when done.
Error handling: Errors stop execution immediately, can retry entire workflow, no state to recover (everything in memory), fast failure and recovery.
Synchronous Workflow Pattern Use Cases
Build synchronous workflows for:
- REST/SOAP API Endpoints - Return data immediately to client requests
- Data Validation Logic - Validate input and return errors instantly
- Format Conversions - Transform CSV to JSON, XML to JSON in real-time
- Database CRUD Operations - Query, insert, update with immediate response
- Calculation Logic - Perform computations and return results
- Real-time Integrations - Call external APIs and return responses
Troubleshooting Synchronous Workflow Issues
| Problem | Detection | Cause | Fix | Notes |
|---|---|---|---|---|
| Workflow timeout | Execution exceeds time limit | Long database query or external API delay | Optimize queries, consider async pattern | If >30 seconds, use async |
| Unexpected long execution | Workflow takes minutes instead of seconds | Processing large datasets synchronously | Split into batches or convert to async | Async better for >30 sec |
Asynchronous Workflow Pattern
Workflows that pause their execution to wait for external events before continuing. Think of them like a manufacturing assembly line that stops at a quality control checkpoint—the product sits on the conveyor belt while a technician performs tests in another department, and the line only resumes moving that specific product forward once the test results come back approved. You follow this pattern when your workflow includes nodes that need to wait, such as the Wait Event Node and Wait Time Node.
Getting Started with Asynchronous Workflows
What an asynchronous workflow looks like:
1 2 3 4 5 | |
You create this pattern when your workflow uses:
- Wait Event Node - Pauses to wait for a specific event to occur
- Wait Time Node - Waits until a specified time or after a delay
Enterprise Scenario: Customer Lead Qualification Process
A CRM system needs to send lead qualification emails to prospects and wait for their response before proceeding:
1 2 | |
- Marketing submits new lead information (Sends an API Request which triggers the workflow via the Start Trigger Node)
- System formats lead data and creates qualification questionnaire (Map Node)
- Sends email to prospect with qualification questions (Script Node)
- Workflow pauses here - could wait hours or days for prospect response (Wait Event Node)
- When prospect replies, workflow resumes and processes their qualification responses (Map Node)
- Updates lead record with qualification status and next steps (Database Node)
This asynchronous pattern handles the reality that prospects need time to respond to qualification emails, which could take anywhere from hours to weeks.
Asynchronous Workflow Pattern Key Characteristics
| Characteristic | Description |
|---|---|
| Execution | Pauses at wait nodes, resumes on events or after configured duration |
| Duration | Minutes to days (spans time) |
| Resources | Released during waits, restored when resuming |
| State | Automatically persisted by Martini during pauses |
| Best For | Email workflows, scheduled jobs, approvals, long processes |
How Asynchronous Workflows Execute in Martini
When you start an asynchronous workflow:
- Martini receives the trigger (Start Trigger Node, Email Trigger Node, Scheduler Node, Webhook Node, or other trigger types)
- Executes nodes until reaching a wait node
- Automatically saves workflow state to persistence
- Releases execution resources (thread, memory)
- Monitors for the trigger event (email, time, webhook)
- Restores saved state when event occurs
- Continues execution from pause point
Resource behavior: Thread released during wait, state persisted to storage, resources freed while waiting, efficiently handles hours/days of waiting.
Error handling: Can resume from last saved state, no need to restart entire workflow, state recovery mechanisms, handles system restarts gracefully.
Why Asynchronous Workflows Are More Resource-Efficient
The key advantage of asynchronous workflows is resource efficiency during waiting periods. Here's what happens under the covers:
Thread Behavior Comparison
SYNCHRONOUS PATTERN (Thread Blocks)
1 2 3 4 5 6 7 8 | |
ASYNCHRONOUS PATTERN (Thread Released)
1 2 3 4 5 6 7 8 | |
Resource Impact Analysis
Synchronous approach (resource inefficient):
- Thread held captive for entire waiting period
- Memory allocated and held throughout
- System resources tied up doing repetitive checking
- If 100 workflows wait for emails = 100 busy threads doing nothing productive
Asynchronous approach (resource efficient):
- Thread immediately released during wait
- Memory freed while waiting, state saved to storage
- One background system monitors all email events
- If 100 workflows wait for emails = 1 background monitor + 100 free threads
The Wait Node Advantage
This is why adding wait nodes is important:
| Wait Duration | Synchronous Impact | Asynchronous Benefit |
|---|---|---|
| 30 seconds | Thread busy for 30s | Thread free for 29.9s |
| 5 minutes | Thread busy for 5min | Thread free for 4min 59s |
| 2 hours | Thread busy for 2hrs | Thread free for 1hr 59min |
| 3 days | Thread busy for 3 days! | Thread free for 2 days 23hrs |
Real-world impact: - Email approval workflow waiting 2 days for response: Synchronous holds expensive resources for 48 hours, Asynchronous releases them immediately - Monthly report waiting 30 days until next run: Synchronous would hold resources for a month, Asynchronous costs almost nothing while waiting - Batch processing with 1000 items needing external confirmations: Synchronous needs 1000 threads, Asynchronous needs background monitoring + threads available for other tasks
How Wait Nodes Create Resource Efficiency
When you use wait nodes in your workflow (Wait Event Node, Wait Time Node), Martini automatically:
- Pauses execution at the wait node - "This workflow needs to wait for something"
- Releases thread and memory resources - "No point holding resources while waiting"
- Saves workflow state to storage - "I need to remember where we left off"
- Resumes when the wait condition is met - "Time to continue from where we paused"
You don't configure this behavior - it's built into how wait nodes work.
Think of it like: A restaurant server (thread) who doesn't stand by your table while your food cooks - they help other customers and return when your order is ready. This allows the restaurant to serve many more customers with the same number of servers.
This is why asynchronous workflows aren't "slower" - they're smarter about resource management during inevitable waiting periods.
Key Martini Nodes That Create Asynchronous Patterns
| Node Type | What It Does | Workflow Behavior |
|---|---|---|
| Wait Event Node | Waits for a specific event to occur | Pauses until event occurs, then continues with event data |
| Wait Time Node | Waits until specific date, time, or recurring schedule | Pauses until time condition met, then continues execution |
Asynchronous Workflow Pattern Use Cases
Build asynchronous workflows for:
- Email-Driven Processes - Send email, wait for reply, process response
- Scheduled Automation - Run tasks daily, weekly, monthly at specific times
- Approval Workflows - Route for approval, wait for decision, proceed accordingly
- Long-Running Business Processes - Multi-day workflows with wait points
- Event-Driven Integrations - Wait for external system callbacks
- Webhook-Based Integrations - Send request, wait for confirmation callback
Real-world examples:
Example 1: Purchase Order Approval
1 2 3 | |
Example 2: Monthly Billing
1 2 3 | |
Example 3: Support Ticket System
1 2 3 | |
Understanding Synchronous vs Asynchronous in Programming Context
In general programming, "synchronous" means operations that block and wait for completion, while "asynchronous" means operations that don't block and can continue or be resumed later. Martini's workflow terminology aligns perfectly with these concepts:
Synchronous workflows (like synchronous function calls):
- Execute all operations in sequence, blocking until each completes
- Thread continues until end of execution, holding all resources throughout
- No resources released until an output is reached
- Not ideal for logic dependent on processes that could take more than a few seconds - causes poor resource management and potential timeouts
Asynchronous workflows (like async/await patterns or event-driven programming):
- Can suspend execution and resume later when external events occur
- Use wait nodes that allow resources to be released while background processes occur
- Thread freed to work on other tasks while waiting for independent processes
- Ideal when a process needed for your logic can take a long time but can execute independently - excellent resource efficiency
Martini's Advantage: Rather than requiring explicit async/await syntax, Martini makes it easier to build asynchronous workflows by providing dedicated wait nodes (Wait Event Node, Wait Time Node) that automatically handle the resource management and thread coordination for you.
Troubleshooting Asynchronous Workflow Issues
| Problem | Detection | Cause | Fix | Notes |
|---|---|---|---|---|
| Workflow never resumes | Stuck in waiting state | Event not received or listener misconfigured | Verify event source, check listener config | Check workflow monitoring |
| Lost state data | Workflow resumes with missing information | State persistence failure | Contact support to verify storage | Rare occurrence |
| Duplicate execution | Same workflow runs multiple times | Duplicate events or retry issues | Implement idempotency checks | Use unique execution IDs |
| Workflow "stuck" but working | Shows waiting status for long time | Normal - waiting for scheduled time or event | Check what event it's waiting for | Not an error |
Understanding Synchronous vs Asynchronous in Programming Context
In general programming, "synchronous" means operations that block and wait for completion, while "asynchronous" means operations that don't block and can continue or be resumed later. Martini's workflow terminology aligns perfectly with these concepts:
Synchronous workflows (like synchronous function calls):
- Execute all operations in sequence, blocking until each completes
- Thread continues until end of execution, holding all resources throughout
- No resources released until an output is reached
- Not ideal for logic dependent on processes that could take more than a few seconds - causes poor resource management and potential timeouts
Asynchronous workflows (like async/await patterns or event-driven programming):
- Can suspend execution and resume later when external events occur
- Use wait nodes that allow resources to be released while background processes occur
- Thread freed to work on other tasks while waiting for independent processes
- Ideal when a process needed for your logic can take a long time but can execute independently - excellent resource efficiency
Martini's Advantage: Rather than requiring explicit async/await syntax, Martini makes it easier to build asynchronous workflows by providing dedicated wait nodes (Wait Event Node, Wait Time Node) that automatically handle the resource management and thread coordination for you.
What Makes Workflows Synchronous or Asynchronous
Understanding what creates each pattern based on the nodes you use in your workflow.
What Makes a Workflow Asynchronous
Your workflow becomes asynchronous when you include wait nodes that pause execution:
Wait nodes that create asynchronous behavior:
- Wait Event Node - Pauses until a specific event occurs
- Wait Time Node - Pauses until a specific time or after a delay
When to use wait nodes:
- Need to wait for email responses from users
- Schedule tasks to run at specific times (daily, weekly, monthly)
- Wait for external system callbacks or confirmations
- Handle approval processes that take time
- Coordinate with long-running external processes
Example scenarios requiring wait nodes:
1 2 3 4 | |
What Makes a Workflow Synchronous
Your workflow remains synchronous when you use standard processing nodes that execute immediately:
Standard nodes that create synchronous behavior:
- Map Node - Transform data formats
- Database Node - Query or update databases
- Script Node - Execute custom logic
- Invoke Service Node - Call existing services
When to use standard nodes:
- Build REST API endpoints that return immediate responses
- Validate input data and return errors instantly
- Transform data between formats (JSON, XML, CSV)
- Perform calculations and return results
- Query databases for immediate responses
Example scenarios using standard nodes:
1 2 3 | |
Pattern Recognition Guide
Look at your workflow to identify the pattern:
1 2 3 4 | |
Visual indicators on your workflow canvas:
- Asynchronous: Workflow has pause points where execution stops and waits
- Synchronous: Workflow flows continuously from start to finish without pauses
Use Case Guidelines
| Your Requirement | Use These Nodes | Result Pattern |
|---|---|---|
| API that updates customer data | Start Trigger Node → Map Node → Database Node → Map Node | Synchronous |
| Send qualification email, wait for response | Start Trigger Node → Script Node → Wait Event Node → Map Node | Asynchronous |
| Daily report generation | Wait Time Node → Database Node → Script Node → Email | Asynchronous |
| Data validation service | Start Trigger Node → Map Node → Validator → Map Node | Synchronous |
| Approval workflow | Script Node → Wait Event Node → Map Node → Database Node | Asynchronous |
| File format converter | Start Trigger Node → Map Node → Transform → Map Node | Synchronous |
How Martini Handles Your Workflow Pattern
Martini handles your workflow behavior automatically based on the nodes you use:
- Contains Wait Event Node, Wait Time Node, or similar nodes → Martini pauses execution at these nodes, saves state, and resumes when events occur
- Contains only processing nodes → Martini runs the workflow continuously from start to finish
- You don't configure this → The behavior emerges naturally from your node choices
Visual Pattern Recognition Guide
Look at your workflow designer:
1 2 3 4 5 6 | |
What Happens Behind the Scenes
For synchronous workflows, Martini:
- Keeps everything in memory during execution
- Maintains active execution thread
- Returns response when complete
- Requires no state persistence
For asynchronous workflows, Martini:
- Saves workflow state when reaching wait node
- Releases execution resources during wait
- Monitors for trigger events
- Restores state and continues when event arrives
- Manages all persistence automatically
Common Questions About Workflow Patterns
Frequently asked questions about synchronous and asynchronous patterns.
Pattern Behavior Questions
Q: What happens if Martini restarts while my async workflow is waiting? A: Martini automatically restores the workflow state and continues waiting. No data is lost because state is persisted before pausing.
Q: My asynchronous workflow seems "stuck"—is this normal? A: Yes, this is normal behavior! Asynchronous workflows pause while waiting for events or the configured duration.
Q: How long can an asynchronous workflow wait? A: As long as needed—hours, days, or weeks. You can optionally set timeout limits as part of the Wait Node's configuration. See Wait Time Node or Wait Event Node for timeout configuration options.
Q: I'm getting timeout errors with my synchronous workflow. What should I do? A: If your synchronous workflow consistently takes longer than 30 seconds, consider converting it to asynchronous. See our troubleshooting guide for step-by-step conversion tips.
Next Steps
After completing this guide:
- Start building workflows: Learn how to create your first workflow in Martini Designer
- Master the visual editor: Explore the Workflow Designer to understand how to add, connect, and configure nodes
- Discover all available nodes: Browse the complete Workflow Nodes reference to see what building blocks are available
- Build asynchronous workflows: Deep dive into Wait Time Node and Wait Event Node for time-based and event-driven workflows
- Join the community: Get help and share examples at Martini Community
Recommended learning path:
- Create your first synchronous workflow (30 minutes)
- Practice with the Workflow Designer interface (30 minutes)
- Experiment with wait nodes for asynchronous patterns (1 hour)
- Build real enterprise scenarios (ongoing)
Helpful Resources
- Martini Designer - Installation and setup guide
- Create a Martini Package - Package management documentation
- Workflow Designer - Visual workflow editor guide
- Data Mapping - Data transformation documentation
- Martini workflow nodes - Complete node reference
- Start Trigger Node - Workflow entry point node
- Map Node - Data transformation node
- Database Node - Database operations node
- Script Node - Custom logic execution node
- Invoke Service Node - Service invocation node
- Wait Event Node - Event-driven wait node
- Wait Time Node - Time-based wait node
- Creating & Deleting Workflows - Workflow lifecycle management
- Community Q&A: Martini Community - Get help and share examples