You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "BewareMyPower (via GitHub)" <gi...@apache.org> on 2023/08/15 09:33:06 UTC

[GitHub] [pulsar-client-python] BewareMyPower commented on a diff in pull request #135: feat: Support dead letter topic.

BewareMyPower commented on code in PR #135:
URL: https://github.com/apache/pulsar-client-python/pull/135#discussion_r1294383629


##########
pulsar/__init__.py:
##########
@@ -374,6 +375,64 @@ def __init__(self, username=None, password=None, method='basic', auth_params_str
             _check_type(str, method, 'method')
             self.auth = _pulsar.AuthenticationBasic.create(username, password, method)
 
+class ConsumerDeadLetterPolicy:
+    """
+    Configuration for the "dead letter queue" feature in consumer.
+    """
+    def __init__(self, dead_letter_topic: str = None,
+                 max_redeliver_count: int = None,
+                 initial_subscription_name: str = None):

Review Comment:
   Please add a test for the default constructor. I made the following change:
   
   ```diff
   diff --git a/tests/pulsar_test.py b/tests/pulsar_test.py
   index 70c1f3a..e749c87 100755
   --- a/tests/pulsar_test.py
   +++ b/tests/pulsar_test.py
   @@ -1723,7 +1723,7 @@ class PulsarTest(TestCase):
            dlq_topic = 'dlq-' + topic
            max_redeliver_count = 5
            consumer = client.subscribe(topic, "my-sub", consumer_type=ConsumerType.Shared,
   -                                    dead_letter_policy=ConsumerDeadLetterPolicy(dlq_topic, max_redeliver_count, 'init-sub'))
   +                                    dead_letter_policy=ConsumerDeadLetterPolicy())
            dlq_consumer = client.subscribe(dlq_topic, "my-sub", consumer_type=ConsumerType.Shared)
    
            # Sen num msgs.
   ```
   
   and found the test failed.
   
   ```
   Traceback (most recent call last):
     File "/Users/xuyunze/github.com/bewaremypower/pulsar-client-python/pulsar_test.py", line 1742, in test_dead_letter_policy
       with self.assertRaises(pulsar.Timeout):
   AssertionError: Timeout not raised
   ```



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org