microsoft / durabletask-java

Java SDK for Durable Functions and the Durable Task Framework
MIT License
13 stars 7 forks source link

Non-blocking Activity task implementations #2

Open cgillum opened 2 years ago

cgillum commented 2 years ago

Issue

The TaskActivity interface is currently has a synchronous run method that returns that output of that activity:

public interface TaskActivity {
    Object run(TaskActivityContext ctx);
}

There's currently no way to define a non-blocking, asynchronous activity implementation. This can result in issues related to the scalability of applications if many activity tasks need to be executed concurrently.

Proposal

There should be an alternative mechanism for implementing non-blocking, asynchronous activity tasks. For example:

public interface AsyncTaskActivity {
    CompletionStage<Object> run(TaskActivityContext ctx);
}

The activity will finish when the CompletionStage is completed.

Other considerations

It should be noted that Azure Functions for Java doesn't yet support non-blocking functions: https://github.com/Azure/azure-functions-java-worker/issues/244. Support for non-blocking activity tasks likely won't benefit Azure Functions users until the Java worker for Azure Functions adds async function support. Unfortunately, there's no indication about if or when this support will be added.