int main(int argc, char** argv) { try { qpid::tests::PingOptions opts; opts.parse(argc, argv); opts.con.heartbeat = (opts.timeout+1)/2; Connection connection; opts.open(connection); if (!opts.quiet) cout << "Opened connection." << endl; AsyncSession s = connection.newSession(); string qname(Uuid(true).str()); s.queueDeclare(queue=qname, autoDelete=true, exclusive=true); s.messageTransfer(content=Message("hello", qname)); if (!opts.quiet) cout << "Sent message." << endl; SubscriptionManager subs(s); subs.get(qname); if (!opts.quiet) cout << "Received message." << endl; s.sync(); s.close(); connection.close(); if (!opts.quiet) cout << "Success." << endl; return 0; } catch (const exception& e) { cerr << "Error: " << e.what() << endl; return 1; } }
~Client() { try { if (connection->isOpen()) { session.close(); connection->close(); } } catch (const std::exception& e) { std::cerr << "Error in shutdown: " << e.what() << std::endl; } }