PROTON-1095: Fixup example broker not to exit at the smallest insult!
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/02251062 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/02251062 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/02251062 Branch: refs/heads/0.12.x Commit: 02251062bda86351d2ba266564a33a0d8db1edde Parents: 2d7d08d Author: Andrew Stitcher <[email protected]> Authored: Tue Jan 26 15:09:01 2016 -0500 Committer: Andrew Stitcher <[email protected]> Committed: Thu Jan 28 10:23:37 2016 -0500 ---------------------------------------------------------------------- examples/cpp/broker.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/02251062/examples/cpp/broker.hpp ---------------------------------------------------------------------- diff --git a/examples/cpp/broker.hpp b/examples/cpp/broker.hpp index c7fd0df..26e42e7 100644 --- a/examples/cpp/broker.hpp +++ b/examples/cpp/broker.hpp @@ -31,6 +31,7 @@ #include "proton/message.hpp" #include "proton/handler.hpp" #include "proton/sender.hpp" +#include "proton/transport.hpp" #include "proton/url.hpp" #include <iostream> @@ -117,7 +118,7 @@ class queues { if (address.empty()) { throw std::runtime_error("empty queue name"); } - + queue*& q = queues_[address]; if (!q) q = new queue(address); @@ -175,7 +176,7 @@ class broker_handler : public proton::handler { void unsubscribe(proton::sender lnk) { std::string address = lnk.local_source().address(); - + if (queues_.get(address).unsubscribe(lnk)) { queues_.erase(address); } @@ -197,9 +198,17 @@ class broker_handler : public proton::handler { remove_stale_consumers(e.connection()); } + void on_transport_error(proton::event &e) { + std::cout << "broker client disconnect: " << e.transport().condition().str() << std::endl; + } + + void on_unhandled_error(proton::event &e, const proton::condition &c) { + std::cerr << "broker error: " << e.name() << ":" << c.str() << std::endl; + } + void remove_stale_consumers(proton::connection connection) { proton::link_range r = connection.find_links(proton::endpoint::REMOTE_ACTIVE); - + for (proton::link_iterator l = r.begin(); l != r.end(); ++l) { if (!!l->sender()) { unsubscribe(l->sender()); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
