DreamPearl commented on code in PR #437:
URL: https://github.com/apache/qpid-proton/pull/437#discussion_r2348730701


##########
cpp/examples/tx_recv.cpp:
##########
@@ -0,0 +1,132 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "options.hpp"
+
+#include <proton/connection.hpp>
+#include <proton/container.hpp>
+#include <proton/message.hpp>
+#include <proton/message_id.hpp>
+#include <proton/messaging_handler.hpp>
+#include <proton/types.hpp>
+#include <proton/transaction_handler.hpp>
+
+#include <iostream>
+#include <map>
+#include <string>
+
+#include <chrono>
+#include <thread>
+
+class tx_recv : public proton::messaging_handler, proton::transaction_handler {
+  private:
+    proton::receiver receiver; 
+    std::string conn_url_;
+    std::string addr_;
+    int expected;
+    int batch_size;
+    int current_batch = 0;
+    int committed = 0;
+
+    proton::session session;
+  public:
+    tx_recv(const std::string& u, const std::string &a, int c, int b):
+        conn_url_(u), addr_(a), expected(c), batch_size(b) {}
+
+    void on_container_start(proton::container &c) override {
+        c.connect(conn_url_);
+    }
+
+   void on_connection_open(proton::connection& c) override {
+        c.open_session();  
+    }
+
+    void on_session_open(proton::session &s) override {
+        s.open_sender(addr_);
+        session = s;
+        std::cout << "Session open, declare_txn" << std::endl;
+        s.declare_transaction(*this);
+    }
+
+    void on_transaction_declare_failed(proton::session) {}
+
+    void on_transaction_commit_failed(proton::session s) {
+        std::cout << "Transaction Commit Failed" << std::endl;
+        s.connection().close();
+        exit(-1);
+    }
+
+    void on_transaction_declared(proton::session s) override {
+        std::cout << "Transaction is declared!" << (&s)
+                  << std::endl;
+        receiver.add_credit(batch_size);
+    }
+
+    void on_message(proton::delivery &d, proton::message &msg) override {
+        std::cout<<"# MESSAGE: " << msg.id() <<": "  << msg.body() << 
std::endl;
+        session.transaction_accept(d);
+        current_batch += 1;
+        if(current_batch == batch_size) {
+        }

Review Comment:
   Ok. I'm not sure what is the intended behaviour for tx_recv.cpp. What does 
commit and abort mean for receiving end?



-- 
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]


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

Reply via email to