Lemline Examples Library
This document provides an overview of the examples available in the Lemline project, organized by category and use case. Each example demonstrates key features of the Open Workflow DSL as implemented by Lemline.
Run the tutorial shop
Start with an order acknowledgement, then reserve, charge and ship an order. The same shop displays the customer confirmation and the warehouse manager's temperature alerts. Each tutorial includes its inputs and expected results.
Run the Examples
Each example on this page is a complete workflow. Complete the SQLite setup and keep its worker running. Run the commands from a second terminal in the setup directory. With the JAR, substitute java -jar lemline.jar for bin/lemline. Start the tutorial shop from the root of the Lemline source checkout:
The event example also needs the tutorial publisher. Save it as tutorial-publisher.yaml and register it:
Introduction
The examples in this library showcase how to implement various workflow patterns using the Open Workflow DSL. These examples range from simple, focused demonstrations of specific features to complex, real-world scenarios that combine multiple features.
Each example follows a consistent pattern:
Document metadata: Defines the DSL version, namespace, workflow name, and version
Workflow structure: Shows the actual workflow definition with tasks, control flow, error handling, etc.
Sample input/output: Where applicable, includes sample input data and expected output
Example Categories
The examples are organized into the following categories:
Basic Workflow Patterns
Basic workflow patterns demonstrate the fundamental building blocks of Open Workflow, such as:
Sequential task execution
Conditional logic with
switchstatementsLoops with
foranddoconstructsNested task execution
Variable setting with
set
Read the available stock in a nested task and pass the result to its parent:
Save it as nested-tasks-example.yaml:
The inner list reads the stock and passes it to its parent: expect {"message":"SKU-1 available: 100"} on a fresh shop.
For more basic patterns, see the Basic Patterns Examples document.
External Service Integration
These examples demonstrate how to integrate with external services through various protocols:
HTTP/REST API calls
OpenAPI integration
gRPC service calls
AsyncAPI for message-based communication
Custom function execution
This example chains two HTTP calls: it searches the catalog, then reads the product it found:
Save it as external-service-integration.yaml:
The first call returns the full response; the workflow exports the ID found in its content, then reads that product: expect the desk lamp, {"id":"SKU-4","name":"Desk lamp","category":"home","price":30,"available":10}.
For more integration examples, see the Integration Examples document.
Error Handling and Resilience
These examples show how to implement robust error handling and resilience patterns:
Try-catch blocks for error handling
Retry mechanisms with backoff strategies
Error type classifications
Compensating transactions
This example retries a failing call with exponential backoff:
Save it as error-handling-and-resilience.yaml:
The shop answers HTTP 503 twice; the catch matches the communication error that a failed HTTP call raises, retries after about 1 and 2 seconds, and the workflow returns the stock. Allow about 30 seconds: the worker picks up retries every 10 seconds.
For more error handling examples, see the Error Handling Examples document.
Data Transformation
These examples demonstrate data manipulation and transformation techniques:
JQ expressions for JSON transformation
Variable setting and manipulation
Data mapping between tasks
Complex transformation patterns
This example sets a value and transforms it in the next task:
Save it as data-transformation.yaml:
Expect {"transformedUser":{"name":"Ada Lovelace","role":"admin","lastAccess":"<current time>"}}, with the time as an ISO 8601 string.
Event Processing
These examples show how to handle events in workflows:
Event listening patterns
Event correlation
Event-driven workflows
Message consumption strategies
This example waits for the first of two event types:
Save it as event-processing.yaml:
Both instances wait. Publish one order event:
The event resumes both listeners: each completes with [{"orderId":"ORD-1003"}]. A listener that receives no event within 30 seconds faults with a timeout error 30 to 40 seconds after it started.
Real-world Examples
These examples combine multiple features to demonstrate realistic use cases:
Order processing workflows
Multi-step approval processes
Data enrichment pipelines
Notification systems
This smaller example routes a digital or physical order to a different fulfillment method:
Save it as real-world-examples.yaml:
Expect {"fulfillment":"digital-delivery"}, then {"fulfillment":"physical-shipping"}.
For more complex examples, see the Real-world Examples document.
Running the Examples
The general form of the commands used above is:
The worker started with bin/lemline listen runs the instance. Stop the shop when you are done:
Conclusion
These examples demonstrate the flexibility and power of the Open Workflow DSL as implemented by Lemline. Use them as a reference when building your own workflows, adapting and combining patterns to suit your specific use cases.
For more detailed explanations of specific patterns, refer to the category-specific documents linked above.