temporalio / sdk-java

Temporal Java SDK
https://temporal.io
Apache License 2.0
200 stars 134 forks source link

Allow users to implement update asynchronously in Java natively #2056

Open Quinn-With-Two-Ns opened 1 month ago

Quinn-With-Two-Ns commented 1 month ago

Is your feature request related to a problem? Please describe. Currently update handlers in Java are all run in their own threads. This means that if the update handler takes a long time and multiple updates are sent the workflow execution can consume lots of threads just waiting in update handlers.

Describe the solution you'd like Support the ability to transform an update call into a Promise that can be completed later in another thread like the main workflow method .

Additional context We have a similar feature to support async activities https://javadoc.io/doc/io.temporal/temporal-sdk/1.0.6/io/temporal/activity/ActivityExecutionContext.html#isUseLocalManualCompletion--

Currently users can do this with the existing SDK API, but it will still consume a thread waiting for the result to return in the handle. If the SDK had a native API for this we wouldn't need to wait in the thread.

mfateev commented 1 month ago

Ideally, the same API can be reused to complete the workflow asynchronously. This would allow workflows to be implemented fully async without tying up a thread when a workflow is cached.