Skip to content

Commit 260d099

Browse files
author
Petr Matousek
committed
transactional receiver first version fixup
1 parent 8d4974e commit 260d099

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

src/api/qpid-proton/reactor/handler/TxReceiverHandler.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -239,44 +239,44 @@ int TxReceiverHandler::getBatchSize() const
239239

240240
// reactor methods
241241

242-
void TxReceiverHandler::on_session_open(session &s) override {
242+
void TxReceiverHandler::on_session_open(session &s) {
243243
sess = s;
244244
std::cout << " [on_session_open] declare_txn started..." << std::endl;
245245
s.declare_transaction(*this);
246246
std::cout << " [on_session_open] declare_txn ended..." << std::endl;
247247
}
248248

249-
void on_transaction_declare_failed(transaction) {}
249+
void TxReceiverHandler::on_transaction_declare_failed(transaction) {}
250250

251-
void on_transaction_commit_failed(proton::transaction t) {
251+
void TxReceiverHandler::on_transaction_commit_failed(transaction t) {
252252
std::cout << "Transaction Commit Failed" << std::endl;
253253
t.connection().close();
254254
exit(-1);
255255
}
256256

257-
void TxReceiverHandler::on_transaction_declared(transaction t) override {
257+
void TxReceiverHandler::on_transaction_declared(transaction t) {
258258
std::cout << "[on_transaction_declared] txn called " << (&t)
259259
<< std::endl;
260260
std::cout << "[on_transaction_declared] txn is_empty " << (t.is_empty())
261-
<< "\t" << transaction.is_empty() << std::endl;
261+
<< "\t" << tx.is_empty() << std::endl;
262262
recv.add_credit(batch_size);
263-
transaction = t;
263+
tx = t;
264264
}
265265

266-
void TxReceiverHandler::on_message(delivery &d, message &msg) override {
266+
void TxReceiverHandler::on_message(delivery &d, message &msg) {
267267
std::cout<<"# MESSAGE: " << msg.id() <<": " << msg.body() << std::endl;
268-
transaction.accept(d);
268+
tx.accept(d);
269269
current_batch += 1;
270270
if(current_batch == batch_size) {
271-
transaction = proton::transaction(); // null
271+
tx = transaction(); // null
272272
}
273273
}
274274

275-
void TxReceiverHandler::on_transaction_committed(transaction t) override {
276-
committed += current_batch;
275+
void TxReceiverHandler::on_transaction_committed(transaction t) {
276+
processed += current_batch;
277277
current_batch = 0;
278-
std::cout<<" [OnTxnCommitted] Committed:"<< committed<< std::endl;
279-
if(committed == expected) {
278+
std::cout<<" [OnTxnCommitted] Processed:"<< processed << std::endl;
279+
if(processed == count) {
280280
std::cout << "All messages committed" << std::endl;
281281
t.connection().close();
282282
}

src/api/qpid-proton/reactor/handler/TxReceiverHandler.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ using proton::codec::encoder;
6060
using proton::binary;
6161
using proton::uuid;
6262
using proton::transaction;
63+
using proton::session;
6364
using proton::transaction_handler;
6465

6566
#ifdef PN_CPP_HAS_STD_FUNCTION
@@ -194,9 +195,9 @@ class TxReceiverHandler : public CommonHandler, transaction_handler {
194195
// reactor methods
195196
void on_container_start(container &c);
196197
void on_message(delivery &d, message &m);
197-
void on_receiver_drain_finish(receiver &r);
198-
void on_tracker_accept(tracker &t);
199-
void on_tracker_reject(tracker &t);
198+
// void on_receiver_drain_finish(receiver &r);
199+
// void on_tracker_accept(tracker &t);
200+
// void on_tracker_reject(tracker &t);
200201
void on_transport_close(transport &t);
201202
void on_transport_error(transport &t);
202203
void on_connection_close(connection &conn);
@@ -259,7 +260,7 @@ class TxReceiverHandler : public CommonHandler, transaction_handler {
259260
string tx_action = "commit";
260261
string tx_endloop_action = "commit";
261262

262-
transaction *tx;
263+
transaction tx;
263264
session sess;
264265
};
265266

0 commit comments

Comments
 (0)