You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Java doesn’t do coroutines, so the current Client implementation is sync. But Kotlin does, and we might benefit from a different async client. I think we can do it like this:
Add an AsyncTask protocol that has an suspend fun execute instead of the sync execute function.
Create an AsyncClient class to use instead of Client. suspend fun execute(client: AsyncClient, context: Context).
When the task is executed, check which protocol is used. Wrap runBlocking around the async task.
Make the annotation processor detect suspend fun so the same @Builder.Task can be used on both sync and async and automatically does the right thing.
The only question is whether we just add Async to both Task and Client. Should the sync version be renamed? (BlockingTask & BlockingClient?)
I thought about this a bit. Since it doesn’t really make much sense to expose this to Java (any language except Kotlin really), it’s probably better to split this into a separate package, or even a separate artifact. Not sure. Probably better than to prefix everything (AsyncClient AsyncTask and so on. I’m not exactly sure what the best approach here is tbh.)
Either way, we should
Create an async equivalent of org.apache.airflow.sdk.execution.Client.
Create an async equivalent of org.apache.airflow.sdk.Client.
Create an async Task interface that requires suspend fun execute(Context, Client) where Client is the async version (Context should be the same).
Extend Dag.add_task() to also accept an async Task, and TaskRunner to handle it.
Extend @Builder.Task to be able to convert an annotated suspend fun to an async Task.
I think it's reasonable to leave this out for now.
Actually, I meant to support "multiplexing" in the Java-SDK execution path, rather than a suspend-based API, since suspend is Kotlin-specific in our previous offline discussion.
Activity
subramanya-dev commentedon May 29, 2026
@uranusjr I’d be happy to work on this feature, please assign it to me if available.
potiuk commentedon May 30, 2026
We do not assign issues - see contributing guide. But feel free to work on it.
uranusjr commentedon Jun 13, 2026
I thought about this a bit. Since it doesn’t really make much sense to expose this to Java (any language except Kotlin really), it’s probably better to split this into a separate package, or even a separate artifact. Not sure. Probably better than to prefix everything (AsyncClient AsyncTask and so on. I’m not exactly sure what the best approach here is tbh.)
Either way, we should
org.apache.airflow.sdk.execution.Client.org.apache.airflow.sdk.Client.suspend fun execute(Context, Client)whereClientis the async version (Contextshould be the same).Dag.add_task()to also accept an async Task, andTaskRunnerto handle it.@Builder.Taskto be able to convert an annotatedsuspend funto an async Task.shaealh commentedon Jul 21, 2026
@uranusjr I opened PR - please review when you get a chance, thanks
jason810496 commentedon Jul 31, 2026
I think it's reasonable to leave this out for now.
Actually, I meant to support "multiplexing" in the Java-SDK execution path, rather than a
suspend-based API, sincesuspendis Kotlin-specific in our previous offline discussion.As Java SDK: Change coordinator comm to use multiplexing #69254 merged, the runtime won't serialized each request and response. There is also an e2e test to exercise the concurrent example:
https://github.com/apache/airflow/blob/e3ea8b29859b6a13f32e8f26d0fae433e58cc3af/java-sdk/example/src/java/org/apache/airflow/example/AnnotationExample.java#L79-L99
Threads and virtual threads are the more common concurrency model in the JVM, Anyway, we can reopen this if the
suspendAPI turns out to be necessary.