Click or drag to resize


Activities are the workhorses of your workflows. Activities are used to interact with the outside world as well as to perform any compute intensive work. Cadence workflows must never interact directly with the outside world and workflow decision tasks are limited to execution times of 60 seconds or less.

Activities are just async methods defined in an activity interface and then implemented in an activity class. Activity interfaces must inherit IActivity and implementations must inherit ActivityBase and implement the activity interface. You must then register your activity implementation with Cadence in your Workflow service.

Here's a simple activity definition:

[ActivityInterface(TaskList = "my-tasks")]
public interface ISendHelloActivity : IActivity
    Task SendHelloAsync(string email, string name);

public class SendHelloActivity : ActivityBase, ISendHelloActivity
    public async Task SendHelloAsync(string email, string name)
        var smtp    = new SmtpClient("");
        var message = new MailMessage("", email);

        message.Body = $"Hello {name}!";


Activity methods can pretty much do whatever they want, including calling REST APIs, querying databases, file and network I/O, as well as creating threads and tasks. Activities can also indicate their liveliness by sending heartbeats to Cadence along with optional checkpoint information that a subsequent run of the activity can use to start where the last run left off.

Activities can call RecordHeartbeatAsync or HeartbeatAsync to record heartbeats. The first method always transmits the heartbeat and should be used when you are recording checkpoint information. The second method is handy when you're just heartbeating to indicate that the activity is still alive.

You'll typically specify a heartbeat timeout for activities that are going to run for a while (more than a minute or two). This can be specified via ActivityOptions when the activity is started or via HeartbeatTimeoutSeconds tagging the activity method. You'll need to record a heartbeat within this timeout internal to prevent Cadence from thinking the activity has crashed and rescheduling your activity.

See Also