Skip to content

Java SDK: Let a native Java Dag set one queue for all its tasks - #74538

Merged
jason810496 merged 6 commits into
apache:mainfrom
jason810496:feature/java-sdk-dag-level-queue
Oct 22, 2026
Merged

jason810496 merged 6 commits into
apache:mainfrom
jason810496:feature/java-sdk-dag-level-queue

Conversation

@jason810496

@jason810496 jason810496 commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Why

Every task of a native Java Dag runs on the Java coordinator, so each one needs a queue that [sdk] queue_to_coordinator routes there. Airflow's Dag has no queue setting, so authors had to repeat the same queue on every task. The Go and TypeScript SDKs already take a Dag-level queue; this gives Java the same.

What changes

queue can be set once on the Dag, in both styles. Each task inherits it, unless the task sets its own queue.

// Annotation style.
@Airflow.Dag(id = "etl", schedule = "@daily", queue = "java")
public class Etl { ... }

// Interface style.
var dag = new DagDef("etl").config("queue", "java");
dag.task("extract", Extract.class);                           // runs on "java"
dag.task("heavy", Heavy.class).config("queue", "java_large"); // its own queue wins
  • Same rules as Go and TypeScript: conditions, switches and TriggerDagRun tasks inherit the queue too, a task's own queue always wins, and the queue is never written on the serialized Dag itself.
  • The native Java examples now set queue = "java", which the README's setup already routes to the Java coordinator.

Was generative AI tooling used to co-author this PR?

@jason810496 jason810496 self-assigned this Oct 10, 2026
@jason810496
jason810496 force-pushed the feature/java-sdk-dag-level-queue branch from d356396 to a591e4e Compare October 14, 2026 07:08
@jason810496
jason810496 marked this pull request as ready for review October 14, 2026 07:32
@jason810496
jason810496 requested a review from uranusjr as a code owner October 14, 2026 07:32

@FrankYang0529 FrankYang0529 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM.

Comment thread java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/DagDef.kt Outdated
@jason810496
jason810496 force-pushed the feature/java-sdk-dag-level-queue branch 2 times, most recently from 8bfb07f to 6a5819f Compare October 20, 2026 02:07
@jason810496 jason810496 added the backport-to-v3-4-test Backport to v3-4-test label Oct 20, 2026
@jason810496 jason810496 added this to the Airflow 3.4.0 milestone Oct 20, 2026
Comment thread java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/DagDef.kt Outdated
Comment thread java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/execution/Serde.kt Outdated
Comment thread java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/execution/Serde.kt Outdated
Comment thread java-sdk/sdk/src/test/kotlin/org/apache/airflow/sdk/execution/SerdeTest.kt Outdated
Comment thread java-sdk/processor/src/test/kotlin/org/apache/airflow/sdk/AirflowProcessorTest.kt Outdated
Comment thread airflow-core/docs/authoring-and-scheduling/language-sdks/java.rst Outdated
@uranusjr

Copy link
Copy Markdown
Member

Should NativeBundleBuilder.java in the e2e suite also be updated to use this?

jason810496 and others added 4 commits October 22, 2026 08:15
Every task of a native Java Dag runs on the Java coordinator, so each one
needs a queue that queue_to_coordinator routes there. Airflow's Dag has no
queue setting, so authors had to repeat the same queue on every task. The
Go and TypeScript SDKs already take a Dag-level queue that each task
inherits unless it sets its own; this gives Java the same.

Co-Authored-By: Claude <noreply@anthropic.com>
A blank queue matched no coordinator, so every task stayed queued.
The parsing docs still said there was no Dag-level queue and routed a
queue the examples do not use.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@jason810496
jason810496 force-pushed the feature/java-sdk-dag-level-queue branch from 3f9633c to 4ed3621 Compare October 22, 2026 08:16

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 0b8708d and 3f9633c.

On NativeBundleBuilder.java: yes, done in 3f9633c. All four e2e Dags (interface, annotation, target, dynamic) now set queue once on the Dag, and no task sets its own.

Comment thread java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/DagDef.kt Outdated
Comment thread java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/execution/Serde.kt Outdated
Comment thread java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/execution/Serde.kt Outdated
Comment thread java-sdk/sdk/src/test/kotlin/org/apache/airflow/sdk/execution/SerdeTest.kt Outdated
Comment thread java-sdk/processor/src/test/kotlin/org/apache/airflow/sdk/AirflowProcessorTest.kt Outdated
Comment thread airflow-core/docs/authoring-and-scheduling/language-sdks/java.rst Outdated
@jason810496
jason810496 requested a review from uranusjr October 22, 2026 08:17
Comment thread java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/execution/Serde.kt Outdated
Comment thread java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/internal/Fields.kt Outdated
Co-Authored-By: Claude <noreply@anthropic.com>

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review.

Comment thread java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/execution/Serde.kt Outdated
Comment thread java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/internal/Fields.kt Outdated
@jason810496
jason810496 merged commit fc9c4b0 into apache:main Oct 22, 2026
82 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-4-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
✅ v3-4-test PR Link

jason810496 added a commit that referenced this pull request Oct 23, 2026
… tasks (#74538) (#75402)

* Java SDK: Let a native Java Dag set one queue for all its tasks

Every task of a native Java Dag runs on the Java coordinator, so each one
needs a queue that queue_to_coordinator routes there. Airflow's Dag has no
queue setting, so authors had to repeat the same queue on every task. The
Go and TypeScript SDKs already take a Dag-level queue that each task
inherits unless it sets its own; this gives Java the same.

* Reject a blank Dag-level queue and fix the native Dag queue docs

A blank queue matched no coordinator, so every task stayed queued.
The parsing docs still said there was no Dag-level queue and routed a
queue the examples do not use.

* Reject a blank Dag-level queue in the annotation processor

* Carry the blank rule on the schema field, for Dag and task queues alike

* Set the queue once per Dag in the e2e native bundle

* Put the blank check on Field and tidy the comments

---------
(cherry picked from commit fc9c4b0)

Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
Co-authored-by: Rahul Vats <43964496+vatsrahul1001@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants