This is an automated email from the ASF dual-hosted git repository.
lizhanhui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
The following commit(s) were added to refs/heads/master by this push:
new 144de699 Fix the method of setting timestamp for Delay Producer.
Before fixing, it may appear that the Message Type cannot be recognized as
DELAY by the server, but rather as NORMAL. (#543)
144de699 is described below
commit 144de699415760eaa72bd9a8dce64e0b3027d4e1
Author: yulangz <[email protected]>
AuthorDate: Sun Oct 8 23:09:27 2023 +0800
Fix the method of setting timestamp for Delay Producer. Before fixing, it
may appear that the Message Type cannot be recognized as DELAY by the server,
but rather as NORMAL. (#543)
Co-authored-by: htaowang <[email protected]>
---
cpp/examples/ExampleProducerWithTimedMessage.cpp | 1 +
cpp/source/rocketmq/ProducerImpl.cpp | 3 +++
2 files changed, 4 insertions(+)
diff --git a/cpp/examples/ExampleProducerWithTimedMessage.cpp
b/cpp/examples/ExampleProducerWithTimedMessage.cpp
index c4623852..8f12f5b6 100644
--- a/cpp/examples/ExampleProducerWithTimedMessage.cpp
+++ b/cpp/examples/ExampleProducerWithTimedMessage.cpp
@@ -77,6 +77,7 @@ int main(int argc, char* argv[]) {
.withCredentialsProvider(credentials_provider)
.withSsl(true)
.build())
+ .withTopics({FLAGS_topic})
.build();
std::atomic_bool stopped;
diff --git a/cpp/source/rocketmq/ProducerImpl.cpp
b/cpp/source/rocketmq/ProducerImpl.cpp
index a56d8037..32b2ecad 100644
--- a/cpp/source/rocketmq/ProducerImpl.cpp
+++ b/cpp/source/rocketmq/ProducerImpl.cpp
@@ -148,6 +148,9 @@ void ProducerImpl::wrapSendMessageRequest(const Message&
message, SendMessageReq
if (delivery_timestamp.time_since_epoch().count()) {
auto duration = delivery_timestamp.time_since_epoch();
system_properties->set_delivery_attempt(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count());
+ auto mutable_delivery_timestamp =
system_properties->mutable_delivery_timestamp();
+
mutable_delivery_timestamp->set_seconds(std::chrono::duration_cast<std::chrono::seconds>(duration).count());
+
mutable_delivery_timestamp->set_nanos(std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count()
% 1000000000);
}
}