summaryrefslogtreecommitdiff
path: root/cpp/examples/direct
diff options
context:
space:
mode:
authorCarl C. Trieloff <cctrieloff@apache.org>2008-11-10 17:05:41 +0000
committerCarl C. Trieloff <cctrieloff@apache.org>2008-11-10 17:05:41 +0000
commitf6f56f56ebb092d8808119a66ced9fcd0399b238 (patch)
tree3c38eba69b014d53a62f20f92722bed6c1b547d0 /cpp/examples/direct
parentc238bdf224cb3ba37c5fb2de06da7f41e98545a2 (diff)
downloadqpid-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/direct')
-rw-r--r--cpp/examples/direct/declare_queues.cpp23
-rw-r--r--cpp/examples/direct/direct_producer.cpp24
-rw-r--r--cpp/examples/direct/listener.cpp23
3 files changed, 45 insertions, 25 deletions
diff --git a/cpp/examples/direct/declare_queues.cpp b/cpp/examples/direct/declare_queues.cpp
index 3289efb872..07e34007a4 100644
--- a/cpp/examples/direct/declare_queues.cpp
+++ b/cpp/examples/direct/declare_queues.cpp
@@ -19,24 +19,28 @@
*
*/
+
/**
* declare_queues.cpp
*
* This program is one of three programs designed to be used
- * together. These programs use the "amq.direct" exchange.
+ * together.
*
- * direct_config_queues.cpp (this program):
+ * declare_queues.cpp: (this program):
*
- * Creates a queue on a broker, binding a routing key to route
- * messages to that queue.
+ * Creates a queue named "message_queue" on a broker, binding the
+ * queue to the "amq.direct" exchange, using the routing key
+ * "routing_key".
*
- * direct_producer.cpp:
+ * direct_producer.cpp
*
- * Publishes to a broker, specifying a routing key.
+ * Publishes to the "amq.direct" exchange, specifying the routing
+ * key "routing_key"
*
- * listener.cpp
+ * listener.cpp
*
- * Reads from a queue on the broker using a message listener.
+ * Reads from the "message_queue" queue on the broker using a
+ * message listener.
*
*/
@@ -56,7 +60,6 @@ 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.direct");
Connection connection;
try {
@@ -70,7 +73,7 @@ int main(int argc, char** argv) {
// routing key is "routing_key" to this newly created queue.
session.queueDeclare(arg::queue="message_queue");
- session.exchangeBind(arg::exchange=exchange, arg::queue="message_queue", arg::bindingKey="routing_key");
+ session.exchangeBind(arg::exchange="amq.direct", arg::queue="message_queue", arg::bindingKey="routing_key");
//-----------------------------------------------------------------------------
diff --git a/cpp/examples/direct/direct_producer.cpp b/cpp/examples/direct/direct_producer.cpp
index 9ea3c812a6..8719fa263f 100644
--- a/cpp/examples/direct/direct_producer.cpp
+++ b/cpp/examples/direct/direct_producer.cpp
@@ -19,26 +19,27 @@
*
*/
-
/**
* direct_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.
+ * together.
*
* create_queues.cpp:
*
- * Creates a queue on a broker, binding a routing key to route
- * messages to that queue.
+ * Creates a queue named "message_queue" on a broker, binding the
+ * queue to the "amq.direct" exchange, using the routing key
+ * "routing_key".
*
* direct_producer.cpp (this program):
*
- * Publishes to a broker, specifying a routing key.
+ * Publishes to the "amq.direct" exchange, specifying the routing
+ * key "routing_key"
*
* listener.cpp
*
- * Reads from a queue on the broker using a message listener.
+ * Reads from the "message_queue" queue on the broker using a
+ * message listener.
*
*/
@@ -65,7 +66,7 @@ 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;
int count = argc>3 ? atoi(argv[3]) : 10;
- string exchange(argc>4 ? argv[4] : "amq.direct");
+
Connection connection;
Message message;
try {
@@ -88,16 +89,13 @@ int main(int argc, char** argv) {
message_data << "Message " << i;
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);
- session.messageTransfer(arg::content=message, arg::destination=exchange);
+ session.messageTransfer(arg::content=message, arg::destination="amq.direct");
}
// 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.direct");
//-----------------------------------------------------------------------------
diff --git a/cpp/examples/direct/listener.cpp b/cpp/examples/direct/listener.cpp
index d199b5c0bb..5fe7138f1e 100644
--- a/cpp/examples/direct/listener.cpp
+++ b/cpp/examples/direct/listener.cpp
@@ -20,10 +20,29 @@
*/
/**
- * listener.cpp: This program reads messages from a queue on
- * the broker using a message listener.
+ * listener.cpp:
+ *
+ * This program is one of three programs designed to be used
+ * together.
+ *
+ * create_queues.cpp:
+ *
+ * Creates a queue named "message_queue" on a broker, binding the
+ * queue to the "amq.direct" exchange, using the routing key
+ * "routing_key".
+ *
+ * direct_producer.cpp
+ *
+ * Publishes to the "amq.direct" exchange, specifying the routing
+ * key "routing_key"
+ *
+ * listener.cpp (this program):
+ *
+ * Reads from the "message_queue" queue on the broker using a
+ * message listener.
*/
+
#include <qpid/client/Connection.h>
#include <qpid/client/Session.h>
#include <qpid/client/Message.h>