Bhargavkonidena commented on code in PR #563:
URL: https://github.com/apache/pulsar-client-cpp/pull/563#discussion_r3019801887
##########
lib/MessageBuilder.cc:
##########
@@ -157,6 +157,12 @@ MessageBuilder& MessageBuilder::disableReplication(bool
flag) {
return *this;
}
+MessageBuilder& MessageBuilder::setNullValue() {
+ checkMetadata();
Review Comment:
I've implemented clearing the payload buffer (impl_->payload =
SharedBuffer()) and made setContent() clear the null_value flag for mutual
exclusivity.
However, I intentionally did not implement clearing partition_key and
ordering_key as suggested. Here's why:
Tombstone messages in Pulsar require a partition key to work with topic
compaction - the key identifies which message is being "deleted".
```
auto msg = MessageBuilder().setPartitionKey("key2").setNullValue().build();
ASSERT_TRUE(msg.hasNullValue());
ASSERT_EQ(msg.getPartitionKey(), "key2"); // Key must be preserved!
```
And the integration test relies on this:
```
auto tombstone =
MessageBuilder().setPartitionKey("key2").setNullValue().build();
producer.send(tombstone); // Tombstone for key2 in compacted topic
```
Clearing the keys would break the tombstone/compaction functionality. This
matches the behavior of the Java client where tombstones retain their keys.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]