arifrhm commented on code in PR #77046:
URL: https://github.com/apache/airflow/pull/77046#discussion_r4593676926


##########
providers/common/messaging/src/airflow/providers/common/messaging/triggers/msg_queue.py:
##########
@@ -68,32 +68,49 @@ class MessageQueueTrigger(BaseEventTrigger):
     def __init__(
         self,
         *,
-        queue: str | None = None,
         scheme: str | None = None,
+        queue: str | None = None,
         trigger_queue: str | None = None,
         **kwargs: Any,
     ) -> None:
-        # Stored under our own name rather than through 
`BaseEventTrigger.__init__(queue=...)` so this
-        # works regardless of the installed airflow-core version, see `queue` 
property below.
-        self._trigger_queue = trigger_queue
-
-        if queue is None and scheme is None:
-            raise ValueError("Either `queue` or `scheme` parameter must be 
provided.")
-
-        # For backward compatibility, queue takes precedence
-        if queue is not None:
+        if queue is not None and (
+            scheme is None or any(provider.queue_matches(queue) for provider 
in MESSAGE_QUEUE_PROVIDERS)
+        ):
             warnings.warn(
-                "The `queue` parameter is deprecated and will be removed in 
future versions. "
+                "Passing the broker queue URI as `queue` is deprecated and 
will be removed in future versions. "
                 "Use the `scheme` parameter instead and pass configuration as 
keyword arguments to `MessageQueueTrigger`.",
                 AirflowProviderDeprecationWarning,
                 stacklevel=2,
             )
             self.queue_uri = queue
-            self.scheme = None
+            queue = None
         else:
             self.queue_uri = None
-            self.scheme = scheme
 
+        if trigger_queue is not None:
+            warnings.warn(
+                "The `trigger_queue` parameter is deprecated and will be 
removed in a future version. "
+                "Use the `scheme` parameter together with `queue` instead to 
assign this trigger to a trigger queue.",
+                AirflowProviderDeprecationWarning,
+                stacklevel=2,
+            )
+
+        if queue is not None and trigger_queue is not None:
+            raise ValueError(
+                "Cannot provide both `queue` and deprecated `trigger_queue`. 
For more details on "
+                "trigger queues, see: "
+                
"https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/deferring.html#controlling-triggerer-host-assignment-per-trigger";
+            )
+
+        if self.queue_uri is None and scheme is None:
+            raise ValueError(
+                "Either `queue` or `scheme` parameter must be provided. For 
more details on "
+                "trigger queues, see: "
+                
"https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/deferring.html#controlling-triggerer-host-assignment-per-trigger";
+            )
+
+        self._trigger_queue = queue if queue is not None else trigger_queue

Review Comment:
   Restored the comment explaining why `self._trigger_queue` is stored directly 
rather than calling `super().__init__(queue=...)`.



##########
providers/common/messaging/src/airflow/providers/common/messaging/triggers/msg_queue.py:
##########
@@ -68,32 +68,49 @@ class MessageQueueTrigger(BaseEventTrigger):
     def __init__(
         self,
         *,
-        queue: str | None = None,
         scheme: str | None = None,
+        queue: str | None = None,
         trigger_queue: str | None = None,
         **kwargs: Any,
     ) -> None:
-        # Stored under our own name rather than through 
`BaseEventTrigger.__init__(queue=...)` so this
-        # works regardless of the installed airflow-core version, see `queue` 
property below.
-        self._trigger_queue = trigger_queue
-
-        if queue is None and scheme is None:
-            raise ValueError("Either `queue` or `scheme` parameter must be 
provided.")
-
-        # For backward compatibility, queue takes precedence
-        if queue is not None:
+        if queue is not None and (
+            scheme is None or any(provider.queue_matches(queue) for provider 
in MESSAGE_QUEUE_PROVIDERS)
+        ):
             warnings.warn(
-                "The `queue` parameter is deprecated and will be removed in 
future versions. "
+                "Passing the broker queue URI as `queue` is deprecated and 
will be removed in future versions. "
                 "Use the `scheme` parameter instead and pass configuration as 
keyword arguments to `MessageQueueTrigger`.",
                 AirflowProviderDeprecationWarning,
                 stacklevel=2,
             )
             self.queue_uri = queue
-            self.scheme = None
+            queue = None
         else:
             self.queue_uri = None
-            self.scheme = scheme
 
+        if trigger_queue is not None:

Review Comment:
   Added a `.. note::` in `docs/changelog.rst` explaining the unification of 
`queue` with trigger queues, the deprecation of `trigger_queue`, and the 
migration path for broker queue URIs.



##########
providers/common/messaging/src/airflow/providers/common/messaging/triggers/msg_queue.py:
##########
@@ -68,32 +68,49 @@ class MessageQueueTrigger(BaseEventTrigger):
     def __init__(
         self,
         *,
-        queue: str | None = None,
         scheme: str | None = None,
+        queue: str | None = None,
         trigger_queue: str | None = None,
         **kwargs: Any,
     ) -> None:
-        # Stored under our own name rather than through 
`BaseEventTrigger.__init__(queue=...)` so this
-        # works regardless of the installed airflow-core version, see `queue` 
property below.
-        self._trigger_queue = trigger_queue
-
-        if queue is None and scheme is None:
-            raise ValueError("Either `queue` or `scheme` parameter must be 
provided.")
-
-        # For backward compatibility, queue takes precedence
-        if queue is not None:
+        if queue is not None and (
+            scheme is None or any(provider.queue_matches(queue) for provider 
in MESSAGE_QUEUE_PROVIDERS)
+        ):
             warnings.warn(
-                "The `queue` parameter is deprecated and will be removed in 
future versions. "
+                "Passing the broker queue URI as `queue` is deprecated and 
will be removed in future versions. "
                 "Use the `scheme` parameter instead and pass configuration as 
keyword arguments to `MessageQueueTrigger`.",
                 AirflowProviderDeprecationWarning,
                 stacklevel=2,
             )
             self.queue_uri = queue
-            self.scheme = None
+            queue = None
         else:
             self.queue_uri = None
-            self.scheme = scheme
 
+        if trigger_queue is not None:
+            warnings.warn(
+                "The `trigger_queue` parameter is deprecated and will be 
removed in a future version. "
+                "Use the `scheme` parameter together with `queue` instead to 
assign this trigger to a trigger queue.",
+                AirflowProviderDeprecationWarning,
+                stacklevel=2,
+            )
+
+        if queue is not None and trigger_queue is not None:
+            raise ValueError(
+                "Cannot provide both `queue` and deprecated `trigger_queue`. 
For more details on "
+                "trigger queues, see: "
+                
"https://airflow.apache.org/docs/apache-airflow/stable/authoring-and-scheduling/deferring.html#controlling-triggerer-host-assignment-per-trigger";
+            )
+
+        if self.queue_uri is None and scheme is None:
+            raise ValueError(
+                "Either `queue` or `scheme` parameter must be provided. For 
more details on "

Review Comment:
   Updated the exception message and unit test validation to `The \`scheme\` 
parameter must be provided.`



##########
providers/common/messaging/tests/unit/common/messaging/triggers/test_msg_queue.py:
##########
@@ -212,12 +212,39 @@ async def mock_run():
 class TestMessageQueueTriggerScheme:
     """Test cases for the new scheme parameter functionality."""
 
-    @pytest.mark.usefixtures("collect_queue_param_deprecation_warning")
+    
@pytest.mark.filterwarnings("ignore::airflow.exceptions.AirflowProviderDeprecationWarning")
     def test_queue_takes_precedence_over_scheme(self):

Review Comment:
   Removed the redundant test `test_queue_takes_precedence_over_scheme`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to