diff options
| author | Carl C. Trieloff <cctrieloff@apache.org> | 2008-11-10 17:05:41 +0000 |
|---|---|---|
| committer | Carl C. Trieloff <cctrieloff@apache.org> | 2008-11-10 17:05:41 +0000 |
| commit | f6f56f56ebb092d8808119a66ced9fcd0399b238 (patch) | |
| tree | 3c38eba69b014d53a62f20f92722bed6c1b547d0 /cpp/examples/fanout | |
| parent | c238bdf224cb3ba37c5fb2de06da7f41e98545a2 (diff) | |
| download | qpid-python-f6f56f56ebb092d8808119a66ced9fcd0399b238.tar.gz | |
QPID-1445 patch from Jonathan
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@712699 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/examples/fanout')
| -rw-r--r-- | cpp/examples/fanout/fanout_producer.cpp | 25 | ||||
| -rw-r--r-- | cpp/examples/fanout/listener.cpp | 26 |
2 files changed, 34 insertions, 17 deletions
diff --git a/cpp/examples/fanout/fanout_producer.cpp b/cpp/examples/fanout/fanout_producer.cpp index bb253d7027..18338717b9 100644 --- a/cpp/examples/fanout/fanout_producer.cpp +++ b/cpp/examples/fanout/fanout_producer.cpp @@ -23,22 +23,21 @@ /** * fanout_producer.cpp: * - * This program is one of three programs designed to be used - * together. These programs do not specify the exchange type - the - * default exchange type is the direct exchange. - * - * declare_queues.cpp: - * - * Creates a queue on a broker, binding a routing key to route - * messages to that queue. + * This program is one of two programs designed to be used + * together. * * fanout_producer.cpp (this program): * - * Publishes to a broker, specifying a routing key. + * Publishes messages to the "amq.fanout" exchange. * * listener.cpp * - * Reads from a queue on the broker using a message listener. + * Creates a private queue, binds it to the "amq.fanout" + * exchange, and reads messages from its queue as they + * arrive. Messages sent before the listener binds the queue are + * not received. + * + * Multiple listeners can run at the same time. * */ @@ -64,7 +63,7 @@ using std::string; int main(int argc, char** argv) { const char* host = argc>1 ? argv[1] : "127.0.0.1"; int port = argc>2 ? atoi(argv[2]) : 5672; - string exchange = argc>3 ? argv[3] : "amq.fanout"; + Connection connection; Message message; try { @@ -87,13 +86,13 @@ int main(int argc, char** argv) { message.setData(message_data.str()); // Asynchronous transfer sends messages as quickly as // possible without waiting for confirmation. - async(session).messageTransfer(arg::content=message, arg::destination=exchange); + async(session).messageTransfer(arg::content=message, arg::destination="amq.fanout"); } // And send a final message to indicate termination. message.setData("That's all, folks!"); - session.messageTransfer(arg::content=message, arg::destination=exchange); + session.messageTransfer(arg::content=message, arg::destination="amq.fanout"); //----------------------------------------------------------------------------- diff --git a/cpp/examples/fanout/listener.cpp b/cpp/examples/fanout/listener.cpp index 2938125f4b..dd9bf3c7ba 100644 --- a/cpp/examples/fanout/listener.cpp +++ b/cpp/examples/fanout/listener.cpp @@ -19,11 +19,29 @@ * */ + /** - * listener.cpp: This program reads messages fro a queue on - * the broker using a message listener. + * listener.cpp + * + * This program is one of two programs designed to be used + * together. + * + * fanout_producer.cpp + * + * Publishes messages to the "amq.fanout" exchange. + * + * listener.cpp (this program) + * + * Creates a private queue, binds it to the "amq.fanout" + * exchange, and reads messages from its queue as they + * arrive. Messages sent before the listener binds the queue are + * not received. + * + * Multiple listeners can run at the same time. + * */ + #include <qpid/client/Connection.h> #include <qpid/client/Session.h> #include <qpid/client/Message.h> @@ -60,7 +78,7 @@ void Listener::received(Message& message) { int main(int argc, char** argv) { const char* host = argc>1 ? argv[1] : "127.0.0.1"; int port = argc>2 ? atoi(argv[2]) : 5672; - string exchange = argc>3 ? argv[3] : "amq.fanout"; + Connection connection; Message msg; try { @@ -83,7 +101,7 @@ int main(int argc, char** argv) { session.queueDeclare(arg::queue=myQueue, arg::exclusive=true, arg::autoDelete=true); - session.exchangeBind(arg::exchange=exchange, arg::queue=myQueue, arg::bindingKey="my-key"); + session.exchangeBind(arg::exchange="amq.fanout", arg::queue=myQueue, arg::bindingKey="my-key"); // Create a listener and subscribe it to my queue. SubscriptionManager subscriptions(session); |
