提交 15d2c3cb 编写于 作者: M Matteo Merli

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.
上级 2d924ab1
......@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册