Skip to content

Commit b9c7219

Browse files
Fix negative acknowledge on a message ID does not work (#180)
Fixes #178 ### Motivation #121 introduces a regression that when `negative_acknowledge` accepts a message ID, the underlying `acknowledgeAsync` method will be called. ### Modifications Fix the `Consumer_negative_acknowledge_message_id` method and add the test for negative acknowledging message IDs in `test_redelivery_count`.
1 parent d278416 commit b9c7219

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/consumer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ void Consumer_negative_acknowledge(Consumer& consumer, const Message& msg) {
6464
}
6565

6666
void Consumer_negative_acknowledge_message_id(Consumer& consumer, const MessageId& msgId) {
67-
waitForAsyncResult([&](ResultCallback callback) { consumer.acknowledgeAsync(msgId, callback); });
67+
Py_BEGIN_ALLOW_THREADS consumer.negativeAcknowledge(msgId);
68+
Py_END_ALLOW_THREADS
6869
}
6970

7071
void Consumer_acknowledge_cumulative(Consumer& consumer, const Message& msg) {

tests/pulsar_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ def test_redelivery_count(self):
286286
for i in range(4):
287287
msg = consumer.receive(TM)
288288
print("Received message %s" % msg.data())
289-
consumer.negative_acknowledge(msg)
289+
if i % 2 == 0:
290+
consumer.negative_acknowledge(msg)
291+
else:
292+
consumer.negative_acknowledge(msg.message_id())
290293
redelivery_count = msg.redelivery_count()
291294

292295
self.assertTrue(msg)

0 commit comments

Comments
 (0)