[
https://issues.apache.org/jira/browse/PROTON-1442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18034960#comment-18034960
]
ASF GitHub Bot commented on PROTON-1442:
----------------------------------------
DreamPearl commented on code in PR #437:
URL: https://github.com/apache/qpid-proton/pull/437#discussion_r2452753083
##########
cpp/include/proton/transaction.hpp:
##########
@@ -0,0 +1,124 @@
+#ifndef PROTON_TRANSACTION_HPP
+#define PROTON_TRANSACTION_HPP
+
+
+/*
+ *
+ * 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 "./fwd.hpp"
+#include "./internal/export.hpp"
+#include "./sender.hpp"
+#include "./tracker.hpp"
+#include "./container.hpp"
+
+/// @file
+/// @copybrief proton::transaction
+
+namespace proton {
+
+class transaction_handler;
+
+// TODO: This should not be accessible to users.
+class transaction_impl {
+ public:
+ proton::sender txn_ctrl;
+ proton::transaction_handler *handler = nullptr;
+ proton::binary id;
+ proton::tracker _declare;
+ proton::tracker _discharge;
+ bool failed = false;
+ std::vector<proton::tracker> pending;
+
+ void commit();
+ void abort();
+ void declare();
+ proton::tracker send(proton::sender s, proton::message msg);
+
+ void discharge(bool failed);
+ void release_pending();
+ void accept(delivery &d);
+ void update(tracker &d, uint64_t state);
+ void set_id(binary _id);
+
+ proton::tracker send_ctrl(proton::symbol descriptor, proton::value _value);
+ void handle_outcome(proton::tracker t);
+ transaction_impl(proton::sender &_txn_ctrl,
+ proton::transaction_handler &_handler,
+ bool _settle_before_discharge);
+
+ // delete copy and assignment operator to ensure no copy of this object is
+ // every made transaction_impl(const transaction_impl&) = delete;
+ // transaction_impl& operator=(const transaction_impl&) = delete;
+};
+
+class
+PN_CPP_CLASS_EXTERN transaction {
+ private:
+ // PN_CPP_EXTERN transaction(proton::sender& _txn_ctrl,
+ // proton::transaction_handler& _handler, bool _settle_before_discharge);
+
+ static transaction mk_transaction_impl(sender &s, transaction_handler &h,
+ bool f);
+ PN_CPP_EXTERN transaction(transaction_impl *impl);
+ transaction_impl *_impl;
+
+ public:
+ // TODO:
+ // PN_CPP_EXTERN transaction(transaction &o);
+ PN_CPP_EXTERN transaction();
+ PN_CPP_EXTERN ~transaction();
+ PN_CPP_EXTERN bool is_empty();
+ PN_CPP_EXTERN void commit();
+ PN_CPP_EXTERN void abort();
+ PN_CPP_EXTERN void declare();
+ PN_CPP_EXTERN void handle_outcome(proton::tracker);
+ PN_CPP_EXTERN proton::tracker send(proton::sender s, proton::message msg);
+ PN_CPP_EXTERN void accept(delivery &t);
+
+ friend class transaction_impl;
+ friend class container::impl;
+};
+
+class
+PN_CPP_CLASS_EXTERN transaction_handler {
+ public:
+ PN_CPP_EXTERN virtual ~transaction_handler();
+
+ /// Called when a local transaction is declared.
+ PN_CPP_EXTERN virtual void on_transaction_declared(transaction);
+
+ /// Called when a local transaction is discharged successfully.
+ PN_CPP_EXTERN virtual void on_transaction_committed(transaction);
+
+ /// Called when a local transaction is discharged unsuccessfully (aborted).
+ PN_CPP_EXTERN virtual void on_transaction_aborted(transaction);
+
+ /// Called when a local transaction declare fails.
+ PN_CPP_EXTERN virtual void on_transaction_declare_failed(transaction);
+
+ /// Called when the commit of a local transaction fails.
+ PN_CPP_EXTERN virtual void on_transaction_commit_failed(transaction);
+};
+
+} // namespace proton
+
Review Comment:
Updated. Now they are session callbacks, transaction_declared() becomes
handler->on_session.open() and on_declare_failed is now handled by
on_session_error().
##########
cpp/include/proton/transaction.hpp:
##########
@@ -0,0 +1,124 @@
+#ifndef PROTON_TRANSACTION_HPP
+#define PROTON_TRANSACTION_HPP
+
+
+/*
+ *
+ * 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 "./fwd.hpp"
+#include "./internal/export.hpp"
+#include "./sender.hpp"
+#include "./tracker.hpp"
+#include "./container.hpp"
+
+/// @file
+/// @copybrief proton::transaction
+
+namespace proton {
+
+class transaction_handler;
+
+// TODO: This should not be accessible to users.
+class transaction_impl {
+ public:
+ proton::sender txn_ctrl;
+ proton::transaction_handler *handler = nullptr;
+ proton::binary id;
+ proton::tracker _declare;
+ proton::tracker _discharge;
+ bool failed = false;
+ std::vector<proton::tracker> pending;
+
+ void commit();
+ void abort();
+ void declare();
+ proton::tracker send(proton::sender s, proton::message msg);
+
+ void discharge(bool failed);
+ void release_pending();
+ void accept(delivery &d);
+ void update(tracker &d, uint64_t state);
+ void set_id(binary _id);
+
+ proton::tracker send_ctrl(proton::symbol descriptor, proton::value _value);
+ void handle_outcome(proton::tracker t);
+ transaction_impl(proton::sender &_txn_ctrl,
+ proton::transaction_handler &_handler,
+ bool _settle_before_discharge);
+
+ // delete copy and assignment operator to ensure no copy of this object is
+ // every made transaction_impl(const transaction_impl&) = delete;
+ // transaction_impl& operator=(const transaction_impl&) = delete;
+};
+
+class
+PN_CPP_CLASS_EXTERN transaction {
+ private:
+ // PN_CPP_EXTERN transaction(proton::sender& _txn_ctrl,
+ // proton::transaction_handler& _handler, bool _settle_before_discharge);
+
+ static transaction mk_transaction_impl(sender &s, transaction_handler &h,
+ bool f);
+ PN_CPP_EXTERN transaction(transaction_impl *impl);
+ transaction_impl *_impl;
+
+ public:
+ // TODO:
+ // PN_CPP_EXTERN transaction(transaction &o);
+ PN_CPP_EXTERN transaction();
+ PN_CPP_EXTERN ~transaction();
+ PN_CPP_EXTERN bool is_empty();
+ PN_CPP_EXTERN void commit();
+ PN_CPP_EXTERN void abort();
+ PN_CPP_EXTERN void declare();
+ PN_CPP_EXTERN void handle_outcome(proton::tracker);
+ PN_CPP_EXTERN proton::tracker send(proton::sender s, proton::message msg);
+ PN_CPP_EXTERN void accept(delivery &t);
Review Comment:
Done
##########
cpp/include/proton/session.hpp:
##########
@@ -36,6 +36,7 @@
struct pn_session_t;
namespace proton {
+ class transaction_impl;
Review Comment:
Removed.
##########
cpp/src/messaging_adapter.cpp:
##########
@@ -116,7 +119,29 @@ void on_delivery(messaging_handler& handler, pn_event_t*
event) {
link_context& lctx = link_context::get(lnk);
Tracing& ot = Tracing::getTracing();
- if (pn_link_is_receiver(lnk)) {
+ if (pn_terminus_get_type(pn_link_remote_target(lnk)) == PN_COORDINATOR) {
+ if (pn_delivery_updated(dlv)) {
+ tracker t(make_wrapper<tracker>(dlv));
+ ot.on_settled_span(t);
+ switch (pn_delivery_remote_state(dlv)) {
+ case PN_ACCEPTED:
+ handler.on_tracker_accept(t);
+ break;
+ case PN_REJECTED:
+ handler.on_tracker_reject(t);
+ break;
+ case PN_RELEASED:
+ case PN_MODIFIED:
+ handler.on_tracker_release(t);
+ break;
+ }
+ if (t.settled()) {
+ handler.on_tracker_settle(t);
+ if (lctx.auto_settle)
+ t.settle();
+ }
+ }
+ } else if (pn_link_is_receiver(lnk)) {
Review Comment:
Removed.
> [c++] Support for transactions
> ------------------------------
>
> Key: PROTON-1442
> URL: https://issues.apache.org/jira/browse/PROTON-1442
> Project: Qpid Proton
> Issue Type: Improvement
> Components: cpp-binding
> Reporter: Radim Kubis
> Assignee: Rakhi Kumari
> Priority: Major
>
> Support for transactions in Qpid Proton C++.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]