A simple, single-threaded broker using the proton::container
. You can use this to run other examples that reqiure an intermediary, or you can use any AMQP 1.0 broker. This broker creates queues automatically when a client tries to send or subscribe.
Uses the broker logic from broker.hpp, the same logic as the proton::connection_engine
broker example engine/broker.cpp.
#include "options.hpp"
#include "broker.hpp"
#include "proton/acceptor.hpp"
#include "proton/container.hpp"
#include "proton/value.hpp"
#include <iostream>
#include <deque>
#include <map>
#include <list>
#include <string>
class broker {
public:
broker(
const proton::url& url) : handler_(url, queues_) {}
private:
class my_handler : public broker_handler {
public:
my_handler(
const proton::url& u, queues& qs) : broker_handler(qs), url_(u) {}
std::cout << "broker listening on " << url_ << std::endl;
}
private:
};
private:
queues queues_;
my_handler handler_;
};
int main(int argc, char **argv) {
options opts(argc, argv);
opts.add_value(url, 'a', "address", "listen on URL", "URL");
try {
opts.parse();
broker b(url);
return 0;
} catch (const bad_option& e) {
std::cout << opts << std::endl << e.what() << std::endl;
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
}
return 1;
}