Skip to content

Conversation

@dingo4dev
Copy link
Contributor

@dingo4dev dingo4dev commented Jun 14, 2025

Closes #515225.

Why

While using the MessageQueueTrigger in Airflow 3.0+, the parameters in the common message queue trigger are not specific enough, leading to potential issues like unclear usage, difficulty in understanding, or unexpected behavior when using it on Kafka

What

This PR introduces the KafkaMessageQueueTrigger class to specify the parameters for the message queue trigger to enhance the usability

@boring-cyborg
Copy link

boring-cyborg bot commented Jun 14, 2025

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@dingo4dev dingo4dev force-pushed the add-kafka-message-queue-trigger branch from 8dba86d to 462cb79 Compare June 14, 2025 04:49
@dingo4dev dingo4dev marked this pull request as ready for review June 14, 2025 04:51
Copilot AI review requested due to automatic review settings June 14, 2025 04:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces the KafkaMessageQueueTrigger to provide a more specific interface for Kafka-based message queues in Airflow, along with a suite of tests, example DAGs, and documentation updates.

  • Adds unit and system tests to verify the new trigger’s behavior.
  • Implements KafkaMessageQueueTrigger and updates provider metadata, documentation, and version numbers accordingly.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
providers/apache/kafka/tests/unit/apache/kafka/triggers/test_msg_queue.py Adds tests to verify queue URI generation and trigger serialization/run behavior for KafkaMessageQueueTrigger.
providers/apache/kafka/tests/system/apache/kafka/example_dag_message_queue_trigger.py Updates example DAG to reference the correct apply_function for MessageQueueTrigger usage.
providers/apache/kafka/tests/system/apache/kafka/example_dag_kafka_message_queue_trigger.py Introduces an example DAG demonstrating usage of KafkaMessageQueueTrigger.
providers/apache/kafka/src/airflow/providers/apache/kafka/triggers/msg_queue.py Implements the KafkaMessageQueueTrigger class with Kafka-specific logic for queue URI generation and connection handling.
providers/apache/kafka/src/airflow/providers/apache/kafka/get_provider_info.py Updates provider info to include the new trigger module.
providers/apache/kafka/src/airflow/providers/apache/kafka/init.py Bumps the version from 1.9.0 to 1.9.1.
providers/apache/kafka/pyproject.toml Updates package version and documentation/changelog URLs.
providers/apache/kafka/provider.yaml Lists the new version 1.9.1.
providers/apache/kafka/docs/triggers.rst Adds documentation for KafkaMessageQueueTrigger.
providers/apache/kafka/docs/message-queues/index.rst Updates message-queue docs to reference the new trigger.
providers/apache/kafka/docs/index.rst Updates version information.
providers/apache/kafka/docs/changelog.rst Adds changelog entries for 1.9.1.
providers/apache/kafka/README.rst Updates version and documentation URLs.

@dingo4dev
Copy link
Contributor Author

TBR

@dingo4dev dingo4dev force-pushed the add-kafka-message-queue-trigger branch from d83536d to 03cebb3 Compare June 16, 2025 00:10
@jason810496 jason810496 self-requested a review June 16, 2025 14:04
Copy link
Contributor

@vincbeck vincbeck left a comment

Choose a reason for hiding this comment

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

nits

@dingo4dev dingo4dev force-pushed the add-kafka-message-queue-trigger branch from 03cebb3 to 482387d Compare June 16, 2025 19:42
@dingo4dev
Copy link
Contributor Author

@vincbeck Thanks for the reviews 😄

Copy link
Member

@jason810496 jason810496 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
After your change, the usage is much more clear.

IMO, we should also update the KafkaMessageQueueProvider to reduce the inconsistency on both side.

We could reuse your get_kafka_queue_uri in KafkaMessageQueueProvider.trigger_kwargs as well.

@dingo4dev
Copy link
Contributor Author

Thanks for the PR!
After your change, the usage is much clear.

IMO, we should also update the KafkaMessageQueueProvider to reduce the inconsistency on both sides.

We could reuse your get_kafka_queue_uri in KafkaMessageQueueProvider.trigger_kwargs as well.

@jason810496 TIA.

ACK. I think we might still need to keep the feasibility for the direct access MessageQueueTrigger.
And we can move the function to utils file/folder for better readability.

Perhaps should we open new PRs for it?

@jason810496
Copy link
Member

Perhaps should we open new PRs for it?

ACK. I think we might still need to keep the feasibility for the direct access MessageQueueTrigger.
And we can move the function to utils file/folder for better readability.

Sure, having a common module as utils is good and refactoring in followup PR is more suitable.

@dingo4dev dingo4dev force-pushed the add-kafka-message-queue-trigger branch 3 times, most recently from ea7a1ec to 84332c1 Compare June 18, 2025 08:35
@dingo4dev dingo4dev force-pushed the add-kafka-message-queue-trigger branch from 84332c1 to 8e22018 Compare June 18, 2025 11:07
@vincbeck vincbeck merged commit e1fa9b1 into apache:main Jun 18, 2025
66 checks passed
@boring-cyborg
Copy link

boring-cyborg bot commented Jun 18, 2025

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@dingo4dev dingo4dev deleted the add-kafka-message-queue-trigger branch June 18, 2025 16:32
RoyLee1224 pushed a commit to RoyLee1224/airflow that referenced this pull request Jun 21, 2025
…bility on Kafka queue (apache#51718)

* WIP feat: add KafkaMessageQueueTrigger for enhanced Kafka message queue operations

* fix: update provider.yaml, tests and lint

* revert manually updated and bumped kafka provider version

* add airflow version checking for tests

* correct formatting in docs

* make linting happy
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.

Add KafkaMessageQueueTrigger as a Convenience Wrapper

4 participants