Watermill and temporal / cadence

Watermill is a Go library for working efficiently with message streams. It is intended as a library for building event-driven applications, enabling event sourcing, CQRS, RPC over messages, sagas.

I’ve had pretty good success with it, but I’m interested in combining it with temporal (or cadence) and wondering if there’s any tips or prior art that anyone is aware of.

Copy pasting my answer from Slack:

Temporal and Watermill solve different problems, or solve problems differently. From a domain perspective, Temporal workflows implement policies and as a result they provide orchestration for the entire process. Nothing stops you from implementing workflows that span through different domains (bounded contexts) though, so if the process is well defined, you can implement it in a single workflow. That gives you the advantage of being able to remediate if any of the steps fail (eg. if the payment fails, the order shouldn’t be sent to shipping).

That’s not always the case though. Sometimes you need to provide integration points in the system that lets actors outside of a business process to react to events which is when Watermill comes into the picture.

Ultimately, the two can be combined very easily. For example, a Temporal activity can send an event to watermill, or a watermill event can start a new workflow.

As a rule of thumb, try to define your business processes. Everything that fits into a single process should be a workflow. Everything else can be watermill events. This is an interesting topic that’s worth exploring, these are just some random thoughts.

2 Likes