pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject [pulsar] branch master updated: Make Python consumers acks async (#3782)
Date Fri, 08 Mar 2019 11:06:06 GMT
This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new d89c8d6  Make Python consumers acks async (#3782)
d89c8d6 is described below

commit d89c8d605991cae56bb057e3347c63bb65ad027b
Author: Matteo Merli <mmerli@apache.org>
AuthorDate: Fri Mar 8 03:06:00 2019 -0800

    Make Python consumers acks async (#3782)
    
    ### Motivation
    
    Fixes #3779
    
    The behavior of acknowledgment has always been to throw exception if consumer is not connected.
    
    In reality it doesn't make much sense to bubble back exception to user in this case because:
     * There's no ack on the ack anyway
     * The only reason for ack to fail is if consumer is disconnected
     * If consumer is disconnected, messages are going to be replayed in any case
     * Therefore, there's no action to do when acking while disconnected
    
    This is already the case in the Java and Go clients (additionally Java client performs
client side grouping of acks based on time).
    
    Changing the Python client behavior to be the same.
---
 pulsar-client-cpp/python/src/consumer.cc | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/pulsar-client-cpp/python/src/consumer.cc b/pulsar-client-cpp/python/src/consumer.cc
index f4379f7..7c2a93a 100644
--- a/pulsar-client-cpp/python/src/consumer.cc
+++ b/pulsar-client-cpp/python/src/consumer.cc
@@ -67,39 +67,19 @@ Message Consumer_receive_timeout(Consumer& consumer, int timeoutMs)
{
 }
 
 void Consumer_acknowledge(Consumer& consumer, const Message& msg) {
-    Result res;
-    Py_BEGIN_ALLOW_THREADS
-    res = consumer.acknowledge(msg);
-    Py_END_ALLOW_THREADS
-
-    CHECK_RESULT(res);
+    consumer.acknowledgeAsync(msg, nullptr);
 }
 
 void Consumer_acknowledge_message_id(Consumer& consumer, const MessageId& msgId)
{
-    Result res;
-    Py_BEGIN_ALLOW_THREADS
-    res = consumer.acknowledge(msgId);
-    Py_END_ALLOW_THREADS
-
-    CHECK_RESULT(res);
+    consumer.acknowledgeAsync(msgId, nullptr);
 }
 
 void Consumer_acknowledge_cumulative(Consumer& consumer, const Message& msg) {
-    Result res;
-    Py_BEGIN_ALLOW_THREADS
-    res = consumer.acknowledgeCumulative(msg);
-    Py_END_ALLOW_THREADS
-
-    CHECK_RESULT(res);
+    consumer.acknowledgeCumulativeAsync(msg, nullptr);
 }
 
 void Consumer_acknowledge_cumulative_message_id(Consumer& consumer, const MessageId&
msgId) {
-    Result res;
-    Py_BEGIN_ALLOW_THREADS
-    res = consumer.acknowledgeCumulative(msgId);
-    Py_END_ALLOW_THREADS
-
-    CHECK_RESULT(res);
+    consumer.acknowledgeCumulativeAsync(msgId, nullptr);
 }
 
 void Consumer_close(Consumer& consumer) {


Mime
View raw message