Created
April 29, 2015 18:04
-
-
Save mbroadst/0adcd6cb1b2c8617a473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <qpid/messaging/Connection.h> | |
#include <qpid/messaging/Message.h> | |
#include <qpid/messaging/Receiver.h> | |
#include <qpid/messaging/Session.h> | |
#include <vector> | |
#include <string> | |
#include <iostream> | |
#include <sstream> | |
using namespace qpid::messaging; | |
int main(int argc, char** argv) | |
{ | |
if (argc < 3) { | |
std::cout << "usage: " << argv[0] << " <broker> <topic>" << std::endl; | |
return 0; | |
} | |
std::string broker = argv[1]; | |
std::string topic = argv[2]; | |
int count = 0; | |
try { | |
Connection connection(broker, "{ protocol: amqp1.0 }"); | |
connection.open(); | |
Session session = connection.createSession(); | |
Receiver receiver = session.createReceiver(topic); | |
receiver.setCapacity(10); | |
Message message; | |
bool done = false; | |
while (receiver.fetch(message)) { | |
session.acknowledge(); | |
} | |
receiver.close(); | |
connection.close(); | |
return 0; | |
} catch(const std::exception& error) { | |
std::cerr << error.what() << std::endl; | |
return 1; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <qpid/messaging/Connection.h> | |
#include <qpid/messaging/Message.h> | |
#include <qpid/messaging/Sender.h> | |
#include <qpid/messaging/Session.h> | |
#include <iostream> | |
#include <iterator> | |
#include <unistd.h> | |
using namespace qpid::messaging; | |
int main(int argc, char** argv) | |
{ | |
if (argc < 3) { | |
std::cout << "usage: " << argv[0] << " <broker> <address>" << std::endl; | |
return 0; | |
} | |
std::string broker = argv[1]; | |
std::string address = argv[2]; | |
try { | |
Connection connection(broker, "{ protocol: amqp1.0 }"); | |
connection.open(); | |
Session session = connection.createSession(); | |
Sender sender = session.createSender(address); | |
while (true) { | |
Message message("test data"); | |
sender.send(message); | |
usleep(300); | |
} | |
connection.close(); | |
return 0; | |
} catch(const std::exception& error) { | |
std::cerr << error.what() << std::endl; | |
return 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment