This is an automated email from the ASF dual-hosted git repository.
xyz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git
The following commit(s) were added to refs/heads/main by this push:
new 1a39e53 [fix][client-cpp] Implement missing
pulsar_message_set_schema_version in C API (#552)
1a39e53 is described below
commit 1a39e5323a2ec07a10cb8dc8b9d4b1c1aea8d324
Author: zhanglistar <[email protected]>
AuthorDate: Tue Mar 17 19:58:04 2026 +0800
[fix][client-cpp] Implement missing pulsar_message_set_schema_version in C
API (#552)
---
include/pulsar/Message.h | 5 +++++
lib/Message.cc | 6 ++++++
lib/RetryableLookupService.h | 4 +++-
lib/c/c_Message.cc | 4 ++++
4 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/include/pulsar/Message.h b/include/pulsar/Message.h
index f52879e..0c67411 100644
--- a/include/pulsar/Message.h
+++ b/include/pulsar/Message.h
@@ -197,6 +197,11 @@ class PULSAR_PUBLIC Message {
*/
const std::string& getSchemaVersion() const;
+ /**
+ * Set the schema version of the message.
+ */
+ void setSchemaVersion(const std::string& schemaVersion);
+
/**
* Get the producer name which produced this message.
*
diff --git a/lib/Message.cc b/lib/Message.cc
index 9505565..df6cff9 100644
--- a/lib/Message.cc
+++ b/lib/Message.cc
@@ -209,6 +209,12 @@ const std::string& Message::getSchemaVersion() const {
return impl_->getSchemaVersion();
}
+void Message::setSchemaVersion(const std::string& schemaVersion) {
+ if (impl_) {
+ impl_->metadata.set_schema_version(schemaVersion);
+ }
+}
+
uint64_t Message::getPublishTimestamp() const { return impl_ ?
impl_->getPublishTimestamp() : 0ull; }
uint64_t Message::getEventTimestamp() const { return impl_ ?
impl_->getEventTimestamp() : 0ull; }
diff --git a/lib/RetryableLookupService.h b/lib/RetryableLookupService.h
index bbcf4f0..7f50cf1 100644
--- a/lib/RetryableLookupService.h
+++ b/lib/RetryableLookupService.h
@@ -18,6 +18,8 @@
*/
#pragma once
+#include <string>
+
#include "LookupDataResult.h"
#include "LookupService.h"
#include "NamespaceName.h"
@@ -64,7 +66,7 @@ class RetryableLookupService : public LookupService {
Future<Result, NamespaceTopicsPtr> getTopicsOfNamespaceAsync(
const NamespaceNamePtr& nsName, CommandGetTopicsOfNamespace_Mode mode)
override {
return namespaceLookupCache_->run(
- "get-topics-of-namespace-" + nsName->toString(),
+ "get-topics-of-namespace-" + nsName->toString() + "-" +
std::to_string(mode),
[this, nsName, mode] { return
lookupService_->getTopicsOfNamespaceAsync(nsName, mode); });
}
diff --git a/lib/c/c_Message.cc b/lib/c/c_Message.cc
index 02c4ce3..cca0460 100644
--- a/lib/c/c_Message.cc
+++ b/lib/c/c_Message.cc
@@ -141,6 +141,10 @@ int pulsar_message_has_schema_version(pulsar_message_t
*message) {
return message->message.hasSchemaVersion();
}
+void pulsar_message_set_schema_version(pulsar_message_t *message, const char
*schemaVersion) {
+ message->message.setSchemaVersion(schemaVersion ? schemaVersion : "");
+}
+
const char *pulsar_message_get_producer_name(pulsar_message_t *message) {
return message->message.getProducerName().c_str();
}