Skip to content

Commit

Permalink
Fix negative acknowledge on a message ID does not work (#180)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
BewareMyPower committed Dec 26, 2023
1 parent d278416 commit b9c7219
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/consumer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ void Consumer_negative_acknowledge(Consumer& consumer, const Message& msg) {
}

void Consumer_negative_acknowledge_message_id(Consumer& consumer, const MessageId& msgId) {
waitForAsyncResult([&](ResultCallback callback) { consumer.acknowledgeAsync(msgId, callback); });
Py_BEGIN_ALLOW_THREADS consumer.negativeAcknowledge(msgId);
Py_END_ALLOW_THREADS
}

void Consumer_acknowledge_cumulative(Consumer& consumer, const Message& msg) {
Expand Down
5 changes: 4 additions & 1 deletion tests/pulsar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ def test_redelivery_count(self):
for i in range(4):
msg = consumer.receive(TM)
print("Received message %s" % msg.data())
consumer.negative_acknowledge(msg)
if i % 2 == 0:
consumer.negative_acknowledge(msg)
else:
consumer.negative_acknowledge(msg.message_id())
redelivery_count = msg.redelivery_count()

self.assertTrue(msg)
Expand Down

0 comments on commit b9c7219

Please sign in to comment.