Getting Started
Particular Service Platform
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Workflows

Business processes typically involve various distributed components that need to be invoked in a coordinated manner. The Particular Service Platform supports both choreography and orchestration of workflows.

Choreography

Choreographed workflows are implemented by an implicit flow of events between services instead of a central owner of a process. Services are highly decoupled by the use of publish/subscribe. Published messages are called events because they describe a fact about something that happened to the rest of the system. Subscribers react to events as required. There is no central state of the workflow.

A choreographed event-driven workflow across multiple endpoints, visualized by a ServiceInsight sequence diagram.

Implementing choreographed workflows

NServiceBus provides a simple publish/subscribe API for all supported messaging technologies. NServiceBus can automatically create and manage the necessary infrastructure like topics, subscriptions, and queues.

Sample: Publish/Subscribe with NServiceBus →

Challenges

  • When implementing complex workflows, messages flowing through the system can quickly become difficult to understand and track. To have a full picture of the message flow, the implementation of every service needs to be known. The absence of a central processor requires more effort to detect failed or stuck business processes. Particular Service Platform monitoring helps to understand and monitor complex choreographed workflows.
  • Putting too much data on events will quickly re-introduce coupling and impact overall system performance. Read more about properly sizing event messages in the blog post on putting events on a diet.
  • Complex workflows that require aggregation of multiple events require local state. Service-internal orchestration using NServiceBus sagas can be used to easily aggregate multiple events and process timeouts in a component of a choreographed workflow.
  • Maintaining a consistent state across all choreography participants in case of failures can become challenging as the coordination and flow of compensating events can quickly multiply the complexity of a choreographed workflow. Choreography is best used for processes that tolerate eventual consistency. Orchestrated workflows may be better for processes that require more consistency.

Orchestration

Orchestrated workflows are managed by a central process that instructs components to perform work in a specific order, manages state, and handles failures. Orchestration can be useful in complex workflows that contain multiple conditions or time-based triggers or have stronger consistency requirements. Instead of events, message-based orchestration relies on commands that the orchestrator sends to receivers that handle them.

Implementing orchestrated workflows

NServiceBus is designed to handle long-running business processes in a robust and scalable way using the saga feature. NServiceBus sagas are a convenient programming model to implement orchestrated, long-running business workflows or state machines using regular C# (or any other .NET language). Sagas handle recoverability, shared state, message correlation, timeouts, and more.

An orchestrated workflow implemented as an NServiceBus Saga, visualized by ServiceInsight.

Tutorial: Introduction to NServiceBus sagas →

Challenges

  • Orchestrators have much higher coupling due to the dependency on the components that are being orchestrated for the workflow. This makes it likely that orchestrators need to change when those components change. Additionally, the orchestrator may require data from those components, further increasing coupling. Orchestration can be a good choice for technical processes within a bounded context, whereas choreography is often a better approach for processes involving more than one bounded context.
  • Orchestrators are more difficult to scale because all workflow communication has to go through the central orchestrator, introducing a potential bottleneck. NServiceBus sagas follow best practices for performance, to optimize integration with all supported data stores for state storage.