#include "options.hpp"
#include "proton/io.hpp"
#include "proton/url.hpp"
#include "proton/event.hpp"
#include "proton/handler.hpp"
#include "proton/link.hpp"
#include "proton/value.hpp"
#include "proton/message_id.hpp"
#include <iostream>
#include <map>
private:
uint64_t expected;
uint64_t received;
public:
simple_recv(const std::string &s, int c) : url(s), expected(c), received(0) {}
std::cout << "simple_recv listening on " << url << std::endl;
}
if (msg.
id().get<uint64_t>() < received)
return;
if (expected == 0 || received < expected) {
std::cout << msg.
body() << std::endl;
received++;
if (received == expected) {
}
}
}
};
int main(int argc, char **argv) {
std::string address("127.0.0.1:5672/examples");
int message_count = 100;
options opts(argc, argv);
opts.add_value(address, 'a', "address", "connect to and receive from URL", "URL");
opts.add_value(message_count, 'm', "messages", "receive COUNT messages", "COUNT");
try {
opts.parse();
simple_recv handler(address, message_count);
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;
}