You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by GitBox <gi...@apache.org> on 2021/12/17 11:13:37 UTC

[GitHub] [qpid-proton] DreamPearl commented on a change in pull request #346: PROTON-2308: Add support for setting Dynamic Node Properties

DreamPearl commented on a change in pull request #346:
URL: https://github.com/apache/qpid-proton/pull/346#discussion_r771315464



##########
File path: cpp/src/link_test.cpp
##########
@@ -23,9 +23,114 @@
 #include <proton/sender_options.hpp>
 #include <proton/receiver_options.hpp>
 #include <proton/container.hpp>
+#include <proton/connection.hpp>
+#include <proton/connection_options.hpp>
+#include <proton/listen_handler.hpp>
+#include <proton/listener.hpp>
+#include <proton/messaging_handler.hpp>
+#include <proton/types.hpp>
+#include <proton/message.hpp>
+#include <proton/target_options.hpp>
+#include <proton/source_options.hpp>
+#include <proton/delivery.hpp>
 
 #include <iostream>
 
+#include <map>
+#include <condition_variable>
+#include <mutex>
+#include <thread>
+
+namespace {
+std::mutex m;
+std::condition_variable cv;
+bool listener_ready = false;
+int listener_port;
+} // namespace
+
+class test_recv : public proton::messaging_handler {
+  private:
+    class listener_ready_handler : public proton::listen_handler {
+        void on_open(proton::listener &l) override {
+            {
+                std::lock_guard<std::mutex> lk(m);
+                listener_port = l.port();
+                listener_ready = true;
+            }
+            cv.notify_one();
+        }
+    };
+
+    std::string url;
+    proton::listener listener;
+    listener_ready_handler listen_handler;
+
+  public:
+    test_recv(const std::string &s) : url(s) {}
+
+    void on_container_start(proton::container &c) override {
+        listener = c.listen(url, listen_handler);
+    }
+
+    void on_message(proton::delivery &d, proton::message &msg) override {
+        proton::symbol sym = "symbol";
+        proton::value val = "value";
+        std::map<proton::symbol, proton::value> props = d.receiver().target().dynamic_node_properties();
+
+        ASSERT(!props.empty());
+        for(auto it=props.begin(); it!=props.end(); it++) {
+            ASSERT_EQUAL(sym, it->first);
+            ASSERT_EQUAL(val, it->second);
+        }
+        d.receiver().close();
+        d.connection().close();
+        listener.stop();
+    }
+};
+
+class test_send : public proton::messaging_handler {
+  private:
+    std::string url;
+    proton::sender sender;
+
+  public:
+    test_send(const std::string &s) : url(s) {}
+
+    void on_container_start(proton::container &c) override {
+        proton::target_options opts;
+        std::map<proton::symbol,proton::value> m({{proton::symbol("symbol"), proton::value("value")}});
+        opts.dynamic_node_properties(m);
+        sender = c.open_sender(url, proton::sender_options().target(opts));
+    }
+
+    void on_sendable(proton::sender &s) override {
+        proton::message msg;
+        msg.body("message");
+        proton::tracker t = s.send(msg);
+        s.connection().close();
+    }
+};
+
+int test_dynamic_node_properties() {

Review comment:
       Well, I am also wondering if the other direction needs to be tested as well or not. I gave it a try (set the properties on the receiver and try to read them from the sender in the same test).
   
   - If I am setting dynamic node properties on the receiver like this `c.receiver_options(proton::receiver_options().source(opts));` and reading it from the sender then the test is getting terminated. And I can not see them getting set in the `attach frame`, plus the SOURCE in the third and fourth attach frame is NULL, which might be the reason for termination.
   
   - But if I am setting it like this`c.receiver_options(proton::receiver_options().target(opts));` , then all is good.
   
   The question is which one is correct or none of them is correct.
   
   Meanwhile, I am looking for resources to get the idea.
   
   Below are the attach frames:
   ```
   [0x1fef6d0]: AMQP:FRAME:0 -> @attach(18) [name="3d0a3e34-a9fd-42b8-9cfd-0b1bbcc9c910", handle=0x0,
   role=false, snd-settle-mode=0x2, rcv-settle-mode=0x0, source=@source(40) [address=null, durable=0x0, expiry-
   policy=null, timeout=0x0, dynamic=false, dynamic-node-properties=null, distribution-mode=null, filter=null, default-
   outcome=null, outcomes=null, capabilities=null], target=@target(41) [address="test", durable=0x0, expiry-policy=null,
    timeout=0x0, dynamic=false, dynamic-node-properties={:symbol="value"}, capabilities=null], unsettled=null, incomplete-
   unsettled=null, initial-delivery-count=0x0, max-message-size=0x0, offered-capabilities=null, desired-capabilities=null,
    properties=null]
   ```
   ```
   [0x7f7ffc002de0]: AMQP:FRAME:0 <- @attach(18) [name="3d0a3e34-a9fd-42b8-9cfd-0b1bbcc9c910", handle=0x0, 
   role=false, snd-settle-mode=0x2, rcv-settle-mode=0x0, source=@source(40) [address=null, durable=0x0, expiry-
   policy=null, timeout=0x0, dynamic=false, dynamic-node-properties=null, distribution-mode=null, filter=null, default-
   outcome=null, outcomes=null, capabilities=null], target=@target(41) [address="test", durable=0x0, expiry-policy=null,
   timeout=0x0, dynamic=false, dynamic-node-properties={:symbol="value"}, capabilities=null], unsettled=null, incomplete-
   unsettled=null, initial-delivery-count=0x0, max-message-size=0x0, offered-capabilities=null, desired-capabilities=null,
   properties=null]
   ```
   ```
   [0x7f7ffc002de0]: AMQP:FRAME:0 -> @attach(18) [name="3d0a3e34-a9fd-42b8-9cfd-0b1bbcc9c910", handle=0x0, 
   role=true, snd-settle-mode=0x2, rcv-settle-mode=0x0, source=null, target=@target(41) [address="test", durable=0x0,
   expiry-policy=null, timeout=0x0, dynamic=false, dynamic-node-properties={:symbol2="value2"}, capabilities=null],
   unsettled=null, incomplete-unsettled=null, initial-delivery-count=0x0, max-message-size=0x0, offered-capabilities=null, 
   desired-capabilities=null, properties=null]
   ```
   ```
   [0x1fef6d0]: AMQP:FRAME:0 <- @attach(18) [name="3d0a3e34-a9fd-42b8-9cfd-0b1bbcc9c910", handle=0x0, role=true,
    snd-settle-mode=0x2, rcv-settle-mode=0x0, source=null, target=@target(41) [address="test", durable=0x0, expiry-
   policy=null, timeout=0x0, dynamic=false, dynamic-node-properties={:symbol2="value2"}, capabilities=null],
   unsettled=null, incomplete-unsettled=null, initial-delivery-count=0x0, max-message-size=0x0, offered-capabilities=null, 
   desired-capabilities=null, properties=null]
   ```
   [Complete logs](https://gist.github.com/DreamPearl/f35d3431a28c0432ad04352c4b0bffa5) 




-- 
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: dev-unsubscribe@qpid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org