This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git


The following commit(s) were added to refs/heads/main by this push:
     new 20e7e6a  PROTON-2427: Avoid message id/correlation id APIs returning 
pn_data_t
20e7e6a is described below

commit 20e7e6afa5fd560d792df87a10f4db3f672fa987
Author: Andrew Stitcher <[email protected]>
AuthorDate: Tue Aug 24 15:39:47 2021 -0400

    PROTON-2427: Avoid message id/correlation id APIs returning pn_data_t
    
    Stop using pn_message_id() and pn_message_correlation_id() APIs for
    setting the message id/correlation id in the examples and in the C++
    binding.
    
    These APIs force inefficient behaviour by returning an inefficent data
    structure that is internal to the message. If we stop using this API we
    can do something more efficient internal to the message in many cases,
    and only fall back to the inefficient behaviour when
    pn_message_id()/pn_message_correlation_id() APIs are used.
    
    We can then also deprecate these APIs.
---
 c/examples/direct.c     | 2 +-
 c/examples/send-abort.c | 2 +-
 c/examples/send-ssl.c   | 2 +-
 c/examples/send.c       | 2 +-
 cpp/src/message.cpp     | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/c/examples/direct.c b/c/examples/direct.c
index a990663..2460c79 100644
--- a/c/examples/direct.c
+++ b/c/examples/direct.c
@@ -80,7 +80,7 @@ static void send_message(app_data_t *app, pn_link_t *sender) {
   /* Construct a message with the map { "sequence": app.sent } */
   pn_message_t* message = pn_message();
   pn_data_t* body = pn_message_body(message);
-  pn_data_put_int(pn_message_id(message), app->sent); /* Set the message_id 
also */
+  pn_message_set_id(message, (pn_atom_t){.type=PN_ULONG, 
.u.as_uint=app->sent});
   pn_data_put_map(body);
   pn_data_enter(body);
   pn_data_put_string(body, pn_bytes(sizeof("sequence")-1, "sequence"));
diff --git a/c/examples/send-abort.c b/c/examples/send-abort.c
index cc88ff0..e79db79 100644
--- a/c/examples/send-abort.c
+++ b/c/examples/send-abort.c
@@ -79,7 +79,7 @@ static pn_bytes_t encode_message(app_data_t* app) {
   pn_message_t* message = pn_message();
   char data[MSG_SIZE + 11] = {0};
   pn_data_t* body;
-  pn_data_put_int(pn_message_id(message), app->sent); /* Set the message_id 
also */
+  pn_message_set_id(message, (pn_atom_t){.type=PN_ULONG, 
.u.as_uint=app->sent});
   body = pn_message_body(message);
   pn_data_enter(body);
   pn_data_put_string(body, pn_bytes(MSG_SIZE, data));
diff --git a/c/examples/send-ssl.c b/c/examples/send-ssl.c
index f4518bf..e4dc495 100644
--- a/c/examples/send-ssl.c
+++ b/c/examples/send-ssl.c
@@ -62,7 +62,7 @@ static pn_bytes_t encode_message(app_data_t* app) {
   /* Construct a message with the map { "sequence": app.sent } */
   pn_message_t* message = pn_message();
   pn_data_t* body = pn_message_body(message);
-  pn_data_put_ulong(pn_message_id(message), app->sent); /* Set the message_id 
also */
+  pn_message_set_id(message, (pn_atom_t){.type=PN_ULONG, 
.u.as_uint=app->sent});
   pn_data_put_map(body);
   pn_data_enter(body);
   pn_data_put_string(body, pn_bytes(sizeof("sequence")-1, "sequence"));
diff --git a/c/examples/send.c b/c/examples/send.c
index 265b66c..f065db0 100644
--- a/c/examples/send.c
+++ b/c/examples/send.c
@@ -61,7 +61,7 @@ static void send_message(app_data_t* app, pn_link_t *sender) {
   pn_data_t* body;
   pn_message_clear(app->message);
   body = pn_message_body(app->message);
-  pn_data_put_int(pn_message_id(app->message), app->sent); /* Set the 
message_id also */
+  pn_message_set_id(app->message, (pn_atom_t){.type=PN_ULONG, 
.u.as_uint=app->sent});
   pn_data_put_map(body);
   pn_data_enter(body);
   pn_data_put_string(body, pn_bytes(sizeof("sequence")-1, "sequence"));
diff --git a/cpp/src/message.cpp b/cpp/src/message.cpp
index 5902ba0..0a3f639 100644
--- a/cpp/src/message.cpp
+++ b/cpp/src/message.cpp
@@ -176,7 +176,7 @@ std::string message::reply_to() const {
 }
 
 void message::correlation_id(const message_id& id) {
-    value(pn_message_correlation_id(pn_msg())) = id;
+    pn_message_set_correlation_id(pn_msg(), id.atom_);
 }
 
 message_id message::correlation_id() const {

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to