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


##########
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:
   Should we add a note in `docs/changelog.rst`? `trigger_queue` was released 
in 2.1.0 and `queue` now means something else when used with `scheme`, users 
upgrading should know about it.



##########
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:
   Why remove the comment explaining why we store it in `_trigger_queue` 
instead of calling `BaseEventTrigger.__init__(queue=...)`? It still applies 
since older cores do not accept `queue`, and now that the names match it is 
tempting to call `super().__init__(queue=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:
+            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:
   nit: `queue` alone now goes to the deprecated broker URI path, so this 
message points users to it. Maybe just say `scheme` 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:
   nit: this test is now the same as 
`test_legacy_queue_uri_with_scheme_keeps_uri_matching` below, I think it can be 
removed



-- 
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