summaryrefslogtreecommitdiff
path: root/cpp/examples
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/examples')
-rw-r--r--cpp/examples/examples/direct/declare_queues.cpp2
-rw-r--r--cpp/examples/examples/direct/direct_producer.cpp6
-rw-r--r--cpp/examples/examples/direct/listener.cpp2
-rw-r--r--cpp/examples/examples/fanout/fanout_producer.cpp6
-rw-r--r--cpp/examples/examples/fanout/listener.cpp5
-rw-r--r--cpp/examples/examples/pub-sub/topic_listener.cpp7
-rw-r--r--cpp/examples/examples/pub-sub/topic_publisher.cpp6
-rw-r--r--cpp/examples/examples/request-response/client.cpp6
-rw-r--r--cpp/examples/examples/request-response/server.cpp7
-rw-r--r--cpp/examples/examples/xml-exchange/declare_queues.cpp2
-rw-r--r--cpp/examples/examples/xml-exchange/listener.cpp2
-rw-r--r--cpp/examples/examples/xml-exchange/xml_producer.cpp6
12 files changed, 32 insertions, 25 deletions
diff --git a/cpp/examples/examples/direct/declare_queues.cpp b/cpp/examples/examples/direct/declare_queues.cpp
index 07c9c63ff6..0cdb472665 100644
--- a/cpp/examples/examples/direct/declare_queues.cpp
+++ b/cpp/examples/examples/direct/declare_queues.cpp
@@ -60,7 +60,7 @@ int main(int argc, char** argv) {
try {
connection.open(host, port);
- Session session = connection.newSession(ASYNC);
+ Session session = connection.newSession();
//--------- Main body of program --------------------------------------------
diff --git a/cpp/examples/examples/direct/direct_producer.cpp b/cpp/examples/examples/direct/direct_producer.cpp
index 9b40f733c2..348b82efae 100644
--- a/cpp/examples/examples/direct/direct_producer.cpp
+++ b/cpp/examples/examples/direct/direct_producer.cpp
@@ -67,7 +67,7 @@ int main(int argc, char** argv) {
Message message;
try {
connection.open(host, port);
- Session session = connection.newSession(ASYNC);
+ Session session = connection.newSession();
//--------- Main body of program --------------------------------------------
@@ -85,7 +85,9 @@ int main(int argc, char** argv) {
message_data << "Message " << i;
message.setData(message_data.str());
- session.messageTransfer(arg::content=message, arg::destination="amq.direct");
+ // Asynchronous transfer sends messages as quickly as
+ // possible without waiting for confirmation.
+ async(session).messageTransfer(arg::content=message, arg::destination="amq.direct");
}
// And send a final message to indicate termination.
diff --git a/cpp/examples/examples/direct/listener.cpp b/cpp/examples/examples/direct/listener.cpp
index 7ee68ebf35..fc2fa96ead 100644
--- a/cpp/examples/examples/direct/listener.cpp
+++ b/cpp/examples/examples/direct/listener.cpp
@@ -65,7 +65,7 @@ int main(int argc, char** argv) {
Message msg;
try {
connection.open(host, port);
- Session session = connection.newSession(ASYNC);
+ Session session = connection.newSession();
//--------- Main body of program --------------------------------------------
diff --git a/cpp/examples/examples/fanout/fanout_producer.cpp b/cpp/examples/examples/fanout/fanout_producer.cpp
index 8ae6bbc242..9a80c86c20 100644
--- a/cpp/examples/examples/fanout/fanout_producer.cpp
+++ b/cpp/examples/examples/fanout/fanout_producer.cpp
@@ -67,7 +67,7 @@ int main(int argc, char** argv) {
Message message;
try {
connection.open(host, port);
- Session session = connection.newSession(ASYNC);
+ Session session = connection.newSession();
//--------- Main body of program --------------------------------------------
@@ -83,7 +83,9 @@ int main(int argc, char** argv) {
message_data << "Message " << i;
message.setData(message_data.str());
- session.messageTransfer(arg::content=message, arg::destination="amq.fanout");
+ // Asynchronous transfer sends messages as quickly as
+ // possible without waiting for confirmation.
+ async(session).messageTransfer(arg::content=message, arg::destination="amq.fanout");
}
// And send a final message to indicate termination.
diff --git a/cpp/examples/examples/fanout/listener.cpp b/cpp/examples/examples/fanout/listener.cpp
index c3123bb944..79a115f99f 100644
--- a/cpp/examples/examples/fanout/listener.cpp
+++ b/cpp/examples/examples/fanout/listener.cpp
@@ -65,7 +65,7 @@ int main(int argc, char** argv) {
Message msg;
try {
connection.open(host, port);
- Session session = connection.newSession(ASYNC);
+ Session session = connection.newSession();
//--------- Main body of program --------------------------------------------
@@ -90,9 +90,6 @@ int main(int argc, char** argv) {
Listener listener(subscriptions);
subscriptions.subscribe(listener, myQueue);
- // Wait for the broker to indicate that our queues have been created.
- session.sync();
-
// Deliver messages until the subscription is cancelled
// by Listener::received()
std::cout << "Listening" << std::endl;
diff --git a/cpp/examples/examples/pub-sub/topic_listener.cpp b/cpp/examples/examples/pub-sub/topic_listener.cpp
index 883d6eba42..4d854e57ff 100644
--- a/cpp/examples/examples/pub-sub/topic_listener.cpp
+++ b/cpp/examples/examples/pub-sub/topic_listener.cpp
@@ -91,7 +91,7 @@ void Listener::prepareQueue(std::string queue, std::string routing_key) {
* the queue name parameter with the Session ID.
*/
- queue += session.getId().str();
+ queue += session.getId().getName();
std::cout << "Declaring queue: " << queue << std::endl;
/* Declare an exclusive queue on the broker
@@ -138,7 +138,7 @@ int main(int argc, char** argv) {
Connection connection;
try {
connection.open(host, port);
- Session session = connection.newSession(ASYNC);
+ Session session = connection.newSession();
//--------- Main body of program --------------------------------------------
@@ -153,9 +153,6 @@ int main(int argc, char** argv) {
listener.prepareQueue("news", "#.news");
listener.prepareQueue("weather", "#.weather");
- // Wait for the broker to indicate that our queues have been created.
- session.sync();
-
std::cout << "Listening for messages ..." << std::endl;
// Give up control and receive messages
diff --git a/cpp/examples/examples/pub-sub/topic_publisher.cpp b/cpp/examples/examples/pub-sub/topic_publisher.cpp
index 94cd3a0f56..edf6ff28f7 100644
--- a/cpp/examples/examples/pub-sub/topic_publisher.cpp
+++ b/cpp/examples/examples/pub-sub/topic_publisher.cpp
@@ -72,7 +72,9 @@ void publish_messages(Session& session, string routing_key)
message_data << "Message " << i;
message.setData(message_data.str());
- session.messageTransfer(arg::content=message, arg::destination="amq.topic");
+ // Asynchronous transfer sends messages as quickly as
+ // possible without waiting for confirmation.
+ async(session).messageTransfer(arg::content=message, arg::destination="amq.topic");
}
}
@@ -101,7 +103,7 @@ int main(int argc, char** argv) {
Message message;
try {
connection.open(host, port);
- Session session = connection.newSession(ASYNC);
+ Session session = connection.newSession();
//--------- Main body of program --------------------------------------------
diff --git a/cpp/examples/examples/request-response/client.cpp b/cpp/examples/examples/request-response/client.cpp
index 073af596bf..eb4c00c2f1 100644
--- a/cpp/examples/examples/request-response/client.cpp
+++ b/cpp/examples/examples/request-response/client.cpp
@@ -114,7 +114,7 @@ int main(int argc, char** argv) {
Message request;
try {
connection.open(host, port);
- Session session = connection.newSession(ASYNC);
+ Session session = connection.newSession();
//--------- Main body of program --------------------------------------------
@@ -157,7 +157,9 @@ int main(int argc, char** argv) {
for (int i=0; i<4; i++) {
request.setData(s[i]);
- session.messageTransfer(arg::content=request, arg::destination="amq.direct");
+ // Asynchronous transfer sends messages as quickly as
+ // possible without waiting for confirmation.
+ async(session).messageTransfer(arg::content=request, arg::destination="amq.direct");
std::cout << "Request: " << s[i] << std::endl;
}
diff --git a/cpp/examples/examples/request-response/server.cpp b/cpp/examples/examples/request-response/server.cpp
index 6c9bc7ffa6..1946facd0e 100644
--- a/cpp/examples/examples/request-response/server.cpp
+++ b/cpp/examples/examples/request-response/server.cpp
@@ -120,7 +120,10 @@ void Listener::received(Message& request) {
// Send it back to the user
response.getDeliveryProperties().setRoutingKey(routingKey);
- session.messageTransfer(arg::content=response, arg::destination="amq.direct");
+
+ // Asynchronous transfer sends messages as quickly as
+ // possible without waiting for confirmation.
+ async(session).messageTransfer(arg::content=response, arg::destination="amq.direct");
}
@@ -131,7 +134,7 @@ int main(int argc, char** argv) {
Message message;
try {
connection.open(host, port);
- Session session = connection.newSession(ASYNC);
+ Session session = connection.newSession();
//--------- Main body of program --------------------------------------------
diff --git a/cpp/examples/examples/xml-exchange/declare_queues.cpp b/cpp/examples/examples/xml-exchange/declare_queues.cpp
index b89f95cd97..1307c473c5 100644
--- a/cpp/examples/examples/xml-exchange/declare_queues.cpp
+++ b/cpp/examples/examples/xml-exchange/declare_queues.cpp
@@ -39,7 +39,7 @@ int main(int argc, char** argv) {
try {
connection.open(host, port);
- Session session = connection.newSession(ASYNC);
+ Session session = connection.newSession();
//--------- Main body of program --------------------------------------------
diff --git a/cpp/examples/examples/xml-exchange/listener.cpp b/cpp/examples/examples/xml-exchange/listener.cpp
index b5e057c4b1..559cfaf8c9 100644
--- a/cpp/examples/examples/xml-exchange/listener.cpp
+++ b/cpp/examples/examples/xml-exchange/listener.cpp
@@ -65,7 +65,7 @@ int main(int argc, char** argv) {
Message msg;
try {
connection.open(host, port);
- Session session = connection.newSession(ASYNC);
+ Session session = connection.newSession();
//--------- Main body of program --------------------------------------------
diff --git a/cpp/examples/examples/xml-exchange/xml_producer.cpp b/cpp/examples/examples/xml-exchange/xml_producer.cpp
index 9333e20438..42e9ec4356 100644
--- a/cpp/examples/examples/xml-exchange/xml_producer.cpp
+++ b/cpp/examples/examples/xml-exchange/xml_producer.cpp
@@ -44,7 +44,7 @@ int main(int argc, char** argv) {
Message message;
try {
connection.open(host, port);
- Session session = connection.newSession(ASYNC);
+ Session session = connection.newSession();
//--------- Main body of program --------------------------------------------
@@ -66,7 +66,9 @@ int main(int argc, char** argv) {
std::cout << "Message data: " << message_data.str() << std::endl;
message.setData(message_data.str());
- session.messageTransfer(arg::content=message, arg::destination="xml");
+ // Asynchronous transfer sends messages as quickly as
+ // possible without waiting for confirmation.
+ async(session).messageTransfer(arg::content=message, arg::destination="xml");
}
// And send a final message to indicate termination.