File tree Expand file tree Collapse file tree 2 files changed +10
-19
lines changed Expand file tree Collapse file tree 2 files changed +10
-19
lines changed Original file line number Diff line number Diff line change @@ -309,26 +309,21 @@ void transaction_impl::release_pending() {
309309
310310void transaction_impl::handle_outcome (proton::tracker t) {
311311 pn_disposition_t *disposition = pn_delivery_remote (unwrap (t));
312+ pn_declared_disposition_t *declared_disp = pn_declared_disposition (disposition);
312313 proton::session session = t.session ();
313314 if (state == State::DECLARING) {
314315 // Attempting to declare transaction
315- proton::value val (pn_disposition_data (disposition));
316- auto vd = get<std::vector<proton::binary>>(val);
317- if (vd.size () > 0 ) {
318- transaction_id = vd[0 ];
319- state = State::DECLARED;
320- handler->on_session_open (session);
321- return ;
322- } else if (pn_disposition_is_failed (disposition)) {
316+ if (pn_disposition_is_failed (disposition)) {
323317 state = State::FREE;
324318 transaction_delete (session);
325319 // on_transaction_declare_failed
326320 handler->on_session_error (session);
327321 return ;
328322 } else {
329- state = State::FREE;
330- transaction_delete (session);
331- handler->on_session_error (session);
323+ pn_bytes_t txn_id = pn_declared_disposition_get_id (declared_disp);
324+ transaction_id = proton::bin (txn_id);
325+ state = State::DECLARED;
326+ handler->on_session_open (session);
332327 return ;
333328 }
334329 } else if (state == State::DISCHARGING) {
Original file line number Diff line number Diff line change @@ -136,15 +136,12 @@ class FakeBroker : public proton::messaging_handler {
136136 }
137137
138138 if (descriptor == " amqp:declare:list" ) {
139+ pn_bytes_t txn_id = pn_bytes (fake_txn_id.size (), reinterpret_cast <const char *>(&fake_txn_id[0 ]));
140+
139141 pn_delivery_t * pd = proton::unwrap (d);
140142 pn_disposition_t * disp = pn_delivery_local (pd);
141- pn_custom_disposition_t *custom_disp = pn_custom_disposition (disp);
142- pn_custom_disposition_set_type (custom_disp, 0x33 );
143- pn_data_t * pn_data = pn_custom_disposition_data (custom_disp);
144- pn_data_put_list (pn_data);
145- pn_data_enter (pn_data);
146- pn_data_put_binary (pn_data, pn_bytes (fake_txn_id.size (), reinterpret_cast <const char *>(&fake_txn_id[0 ])));
147- pn_data_exit (pn_data);
143+ pn_declared_disposition_t * declared_disp = pn_declared_disposition (disp);
144+ pn_declared_disposition_set_id (declared_disp, txn_id);
148145 pn_delivery_settle (pd);
149146
150147 std::cout << " [BROKER] transaction declared: " << fake_txn_id << std::endl;
@@ -304,7 +301,6 @@ int main(int argc, char** argv) {
304301 std::thread client_thread ([&client_container]() -> void { client_container.run (); });
305302
306303 RUN_ARGV_TEST (tests_failed, test_transaction_commit (broker, client));
307- // RUN_ARGV_TEST(tests_failed, test_transaction_abort(broker, client));
308304
309305 broker_thread.join ();
310306 client_thread.join ();
You can’t perform that action at this time.
0 commit comments