ELSA 3.0

By Sipke Schoorstra · 2023-12-31

ELSA 3.0

Unleash the power of workflows in your .NET projects. Table of Contents · Introducing Elsa 3.0 · Known Issues & Limitations · What’s New · A Brief History ∘ 1.0: Laying the Foundation ∘...

Unleash the power of workflows in your .NET projects.

Table of Contents

· Introducing Elsa 3.0
· Known Issues & Limitations
· What’s New
· A Brief History
∘ 1.0: Laying the Foundation
∘ 2.0: Advancing the Framework
∘ 3.0: A New Era in Workflow Automation
· Rethinking the Activity Model
∘ Dependency Injection
· New Designer
∘ Enhanced Designer Capabilities: Composable Activities
∘ Design workflows as activities
· Implicit Join & Fork
· More expressions: C# & Python
· Lock free Workflow Execution
∘ The Power of Virtual Actors
· Giving Elsa a Spin
∘ 1. Run Elsa Studio + Server Docker Image
∘ 2. Login
∘ 3. Import the Sample Workflow
∘ 4. Publish the Workflow
∘ 5. Run the Workflow
· Use Cases
· The Road Ahead
∘ Commitment to Core Principles
∘ Operational Excellence
∘ Multi-Tenancy
∘ Embracing Industry Standards with BPMN 2.0
∘ Introducing Elsa Capsules
· Predictable Release Cadence
· Strengthening Elsa: Commercial Support
∘ Commitment to Open Source
· Migrating from Elsa 2 to Elsa 3
· Get Involved
· Shaping the Future

Introducing Elsa 3.0

A Milestone Release

We are thrilled to announce the release of Elsa 3.0, now available on NuGet. This release marks a significant leap forward in our journey towards simplifying and enhancing workflow automation.

What is Elsa Workflows?

For those new to Elsa Workflows, here’s a quick overview: Elsa is a robust suite of NuGet packages designed for building flexible workflow servers. These can be seamlessly integrated within your existing applications or can function as standalone servers. With support for communication via HTTP, AMQP, and other protocols, Elsa is engineered to cater to a diverse range of integration requirements.

Known Issues & Limitations

Elsa is continually evolving, and while it offers powerful capabilities, there are some known limitations and ongoing work:

What’s New

Elsa 3.0 is not just an update; it’s a complete rewrite of Elsa 2 with a host of innovative features and improvements. Here’s a glimpse of what this exciting new release brings to the table:

Elsa 3.0 embodies our commitment to delivering a powerful, flexible, and efficient workflow automation tool. These enhancements are just the beginning of what promises to be a transformative experience for our users.

A Brief History

The Journey from 1.0 to 2.0

Understanding Elsa’s evolution offers valuable insights into its current capabilities. Let’s take a walk down memory lane:

1.0: Laying the Foundation

Elsa 1 workflow designer
Elsa 1 designer

2.0: Advancing the Framework

Elsa 2 designer

Elsa 2.0 marked a significant step in the right direction, but it was clear that further advancements were necessary to fully realise the vision of a versatile, scalable workflow engine.

3.0: A New Era in Workflow Automation

Building on Past Learnings

Elsa 3.0 represents a paradigm shift, a version reimagined from the ground up, taking into account the invaluable lessons from Elsa 2.0. This iteration introduces a suite of groundbreaking features and improvements:

In the following sections, we dive deeper into each of these transformative features.

Rethinking the Activity Model

Inspiration and Innovation

One of our primary goals with Elsa 3.0 was to reimagine the activity model. We drew inspiration from the Windows Workflow Foundation (WF) and its dynamic approach to constructing workflows. WF’s model allows for the on-the-fly creation of workflows by instantiating activities and setting their properties, including child activities.

var workflow = new Sequence 
{
Activities =
{
new WriteLine
{
Text = "Hello Windows Workflow Foundation!"
}
}
}

Now, let’s see how this translates in Elsa 3.0:

var workflow = new Sequence
{
Activities =
{
new WriteLine("Hello Elsa 3.0!") // Used ctor overload to initialize Text property directly
}
};

The structure remains strikingly similar, maintaining the straightforward and intuitive nature of workflow definition. However, a small enhancement in Elsa 3.0 is the introduction of constructor overloads for commonly used properties, such as the Text property in the WriteLine activity. This refinement simplifies the process of initialising activity properties, making the workflow creation a bit more efficient and user-friendly.

Dependency Injection

Simplifying Activity Creation

We’ve made a significant shift in how activities are created and managed. Unlike Elsa 2, where activities were instantiated via a service container (Dependency Injection or DI), Elsa 3 adopts a more straightforward approach.

Constructor Flexibility

Activities in Elsa 3 are simple .NET types, which you instantiate directly to construct a workflow. This change gives activity developers the flexibility to decide which constructors to expose. Best practices suggest having a default constructor and, optionally, overloads for frequently used properties. This shift streamlines workflow composition.

Accessing Application Services

You might wonder how activities in Elsa 3 access application services. The process is elegantly simple and mirrors the method used in Windows Workflow Foundation (WF). In Elsa 3, a custom activity can implement an ExecuteAsync method, which receives an ActivityExecutionContext. Services are then resolved from the Service Provider within this context. Here's a snippet to illustrate:

public class MyActivity : CodeActivity
{
protected override void Execute(ActivityExecutionContext context)
{
var myService = context.GetRequiredService<IMyService>();
}
}

Towards a Fluid API

Although Elsa 3 does not currently have a fluid API for constructing workflows from activities, the architecture is conducive to adding one in the future, potentially supporting property dependency injection.

Enhanced Scheduling

A groundbreaking feature of Elsa 3 is the autonomy given to activities to schedule other activities. This capability transforms an activity into a self-contained state machine, enhancing the workflow’s flexibility. In this model, an activity signals its completion, prompting its parent to schedule the next activity based on its logic. This decoupling from the traditional flowchart logic means that the scheduler’s role is now to simply execute the next activity, regardless of its complexity or type, be it a flowchart, sequence, state machine diagram, or potentially a BPMN 2.0 diagram. While the latter two are not yet implemented, the architecture lays the groundwork for their future inclusion.

New Designer

A Fusion of Functionality and Ease

Elsa 3.0 introduces a revamped designer that synthesises the best features of its predecessors while introducing new, user-centric functionalities:

Elsa 3.0’s designer represents a significant leap forward. It’s designed to cater to the needs of both novice users and experienced workflow designers, making it a versatile tool for a wide range of applications.

Elsa 3 designer

Enhanced Designer Capabilities: Composable Activities

Encapsulating Complexity with Ease

A key innovation in Elsa 3.0 is the enhanced support for composable activities within the designer. This feature fundamentally changes how workflows are constructed, allowing for a more intuitive and efficient design process.

For example, consider a high-level orchestration of a change request process. Something like this, perhaps:

A 3-step change request process

Each step is a Container activity that itself performs no logic, other than scheduling the activity assigned to its Body property.

The Body property, being of type IActivity, can support any kind of activity that implements this interface. When using the designer, it will automatically create a new Flowchart activity and assign it to the Body of the Container activity. The flowchart in turn can contain activities that implement a given step in the process. For example, the “Review Change Request” flowchart of the second step might look like this:

The contents of the “Review Change Request” container activity

Design workflows as activities

Intuitive Reusability

Elsa 3.0 takes the concept of reusable workflows to the next level by allowing workflows to be designed as activities directly within the designer. This innovation not only simplifies the creation process but also automatically versions composite activities for better management and evolution over time.

For example, the following represents a workflow that returns the sum of its inputs:

A workflow definition called “Sum” that is useable as an activity

The above screenshot demonstrates an implementation of a workflow called Sum (1) that is usable as an activity (2) under the category Math (3).

The Sum workflow accepts one input called Values (an array) and one output called Result

When the workflow executes, it will execute the RunJavaScript activity, which returns the sum of the values provided as input, which gets bound to the Result output of the workflow.

With this setup, we can now reuse this workflow as an activity in other workflows. For example, let’s take a look at the following workflow called Calculator:

Invoking the Sum workflow as an activity

This workflow uses the Sum workflow as an activity and captures its Result output into a variable, which can then be used by the WriteLine activity to print out the sum. When running this workflow, the result looks like this:

The workflow instance viewer of the Calculator workflow

As you can see, the Sum activity (1) received its input values via its Values input property (2) and produced an output of 88 via its Result output property (3). Notice also that this output was captured in a workflow variable called Sum (4), which is then used by the WriteLine activity to print out the result to the console.

Workflows executing as activities run synchronously and don’t produce speearate workflow instances. In fact, what happens under the hood is that the engine simply takes the activities and schedules them for execution.

Elsa 3.0’s approach to designing workflows as activities offers a flexible and powerful way to construct complex processes with modular components that are easy to manage, version, and integrate into broader systems.

Implicit Join & Fork

Simplified Workflow Branching

Elsa 3.0 introduces a significant simplification to workflow design with its implicit join and fork capabilities:

Elsa 3.0’s approach to forking and joining represents a leap towards more agile and maintainable workflow designs, providing a more natural way to model concurrent processes and their synchronisation.

Implicit Fork & Join

If you need a Wait Any join mode instead, add an explicit Join activity and configure its Mode to Wait Any (the default for this activity).

Explicit Join (Wait Any)

The Wait Any join mode will continue workflow execution as soon as one of its inbound activities complete, and will automatically clear any bookmarks created by any of its inbound activities. In the above example, if the Event arrives before the Timer triggers, the Timer will be canceled.

More expressions: C# & Python

Broadening the Horizons

Elsa 3.0 introduces support for two powerful and widely-used programming languages:

An example of a C# expression used in the Text input for a WriteLine activity

Both languages can be enriched with custom types and functions, similar to how it is done in JavaScript and Liquid.

Lock free Workflow Execution

Dual Runtime Implementations for Maximum Flexibility

Elsa 3 ships with two runtime implementations:

The Power of Virtual Actors

Elsa 3.0’s adoption of lock-free execution via the Actor Model opens up new possibilities for performance and scalability, positioning Elsa as a cutting-edge platform for building and managing complex workflows in modern applications.

Giving Elsa a Spin

If you want to have a quick look, you can follow these steps to try it out using a Docker image.

1. Run Elsa Studio + Server Docker Image

Run the following command to pull the latest version of the Elsa Docker image and run it on port 13000:

docker pull elsaworkflows/elsa-server-and-studio-v3:latest
docker run -t -i -e ASPNETCORE_ENVIRONMENT='Development' -e HTTP_PORTS=8080 -p 13000:8080 elsaworkflows/elsa-server-and-studio-v3:latest
Make sure you have Docker for Desktop installed before attempting to run Docker images.

2. Login

Open a web browser window and navigate to http://localhost:13000/, then login with the default admin credentials, which are:

Username: admin
Password: password

3. Import the Sample Workflow

First, download this sample workflow.

Then navigate to Workflows -> Definitions and click the little arrow on the Create Workflow button and select Import.

Click the arrow

Select the workflow file you just downloaded. A new workflow appears in the list.

The imported workflow appears in the list

4. Publish the Workflow

Before we can run the workflow, make sure it is published. To do so, click on the triple dots at the far right of the workflow and select Publish.

Publish the imported workflow

5. Run the Workflow

Now that the workflow is published, we can invoke it. This particular workflow exposes itself as an HTTP endpoint that accepts POST requests and a payload that it will transform using a given script syntax.

The sample workflow

Here’s a sample curl you can try via e.g. Postman:

curl --location 'http://localhost:13000/api/workflows/test?script=csharp' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"array": [
"test"
]
}
}'

The response should look like this:

{
"data": {
"object1": "test"
}
}

This workflow demonstrates a few key features:

Use Cases

Where Flexibility Meets Efficiency

Elsa’s capabilities are extensive and varied, making it a suitable choice for a wide array of applications. It excels in orchestrating both asynchronous, long-running processes as well as handling synchronous, short-running tasks with speed and precision.

Here are some typical use cases for using Elsa:

  1. Business Process Automation: Elsa can automate complex business processes, such as order processing, employee onboarding, or customer service operations. This involves orchestrating various tasks like data entry, approvals, notifications, and integrating with other business systems.
  2. Workflow-Driven Web Applications: It can be used to drive the logic behind web applications. For instance, managing user interactions, data processing, and decision-making processes in an e-commerce site or a customer portal.
  3. Scheduled Tasks and Background Jobs: Elsa is suitable for scheduling and executing background tasks, such as nightly data synchronisation, periodic cleanup of database records, or generating and distributing reports at specific intervals.
  4. Integration with External Services: The engine can be used to integrate disparate systems and services. This includes connecting to APIs, sending and receiving messages from message queues, or interfacing with custom software components.
  5. Event-Driven Architectures: Elsa can handle event-driven architectures by responding to various events such as file uploads, database changes, or external webhook calls. This allows for reactive programming models where actions are triggered by specific events rather than being scheduled or run continuously.
  6. Robotic Process Automation (RPA): Elsa serves as a robust foundation for implementing RPA, streamlining the automation of repetitive and rule-based tasks typically performed by human users. Whether it’s extracting data from documents, filling out forms, or performing routine transactions, Elsa can coordinate these tasks across multiple systems without manual intervention. By creating workflows that mimic user interactions and integrate with cognitive services for tasks such as OCR and decision-making, Elsa enhances operational efficiency, reduces errors, and frees up human resources for more complex activities.

The Road Ahead

Today’s release is a big milestone, showcasing a wealth of innovative features. However, it also marks the beginning of more to come.

Commitment to Core Principles

Operational Excellence

Multi-Tenancy

Embracing Industry Standards with BPMN 2.0

Introducing Elsa Capsules

Predictable Release Cadence

Scheduled Stability and Enhancements

As Elsa continues to evolve, we are establishing a regular release cadence that prioritises stability and forward compatibility:

This approach to release cadence is a testament to our dedication to delivering a reliable, robust workflow engine that supports the growing needs of our users while maintaining the integrity of their existing workflows.

Strengthening Elsa: Commercial Support

Sustaining Open Source with Expert Backing

Elsa’s journey from a project nurtured by a dedicated few to a widely-used open source workflow engine is a story of community and innovation. Recognising the need for sustainable development and support:

Commitment to Open Source

Elsa’s evolution into a commercially supported framework is about providing assurance and advanced capabilities to enterprises, without compromising the open source ethos that is the heart of Elsa’s community.

Migrating from Elsa 2 to Elsa 3

Acknowledging the Evolutionary Leap

Elsa 3 represents a transformative progression from its predecessor, embracing an architecture that sets a new benchmark for workflow automation. We understand that migration from Elsa 2 to 3 is a significant undertaking:

Get Involved

Join Our Community

Whether you’re looking to explore more, contribute, or simply engage with fellow users, here are some ways you can dive deeper into the Elsa ecosystem:

  1. Explore the Documentation: Get a comprehensive understanding of Elsa and its capabilities. Our documentation is a great starting point for both new and experienced users.
  2. Contribute on GitHub: Your contributions can help shape Elsa’s future. Whether it’s code, bug reports, or feature suggestions, every contribution counts.
  3. Connect on Discord: Join our Discord server to engage with a community of Elsa enthusiasts. It’s a space for discussions, questions, and sharing experiences.
  4. Ask Questions on StackOverflow: Have specific queries or facing challenges with Elsa? Head over to StackOverflow, tag your questions with the ‘elsa-workflow’ tag, and tap into the collective knowledge of the Elsa community for swift assistance and insights.

Shaping the Future

Your Voice Matters

Elsa’s journey is driven by the voices of its users. Your insights and opinions are not just heard but are integral to the evolution of Elsa. We genuinely value your feedback — what works, what doesn’t, and everything in between.

As Elsa evolves, your feedback is instrumental in refining its capabilities. This release marks a significant step in our ongoing effort to provide a powerful and efficient workflow engine and we’re excited to see where your feedback, suggestions, and ideas will take us next!