diff options
| author | Gordon Sim <gsim@apache.org> | 2013-08-13 15:06:42 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2013-08-13 15:06:42 +0000 |
| commit | 144f3c698bdddf22509691a4f285305e9fd83291 (patch) | |
| tree | 2a399e0c06586c0ab5cab8986eb317767ac4080d /qpid/cpp/examples | |
| parent | 4c5376ff911c42a9e43115d38c6751573d8af514 (diff) | |
| download | qpid-python-144f3c698bdddf22509691a4f285305e9fd83291.tar.gz | |
QPID-5040: support for sending and receiving messages with AmqpValue sections
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1513536 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/examples')
| -rw-r--r-- | qpid/cpp/examples/messaging/drain.cpp | 10 | ||||
| -rw-r--r-- | qpid/cpp/examples/messaging/map_receiver.cpp | 8 | ||||
| -rw-r--r-- | qpid/cpp/examples/messaging/map_sender.cpp | 6 | ||||
| -rw-r--r-- | qpid/cpp/examples/messaging/spout.cpp | 2 |
4 files changed, 11 insertions, 15 deletions
diff --git a/qpid/cpp/examples/messaging/drain.cpp b/qpid/cpp/examples/messaging/drain.cpp index 563e5e5060..fe4ea7950d 100644 --- a/qpid/cpp/examples/messaging/drain.cpp +++ b/qpid/cpp/examples/messaging/drain.cpp @@ -90,13 +90,11 @@ int main(int argc, char** argv) int count = options.getCount(); Message message; int i = 0; - + while (receiver.fetch(message, timeout)) { std::cout << "Message(properties=" << message.getProperties() << ", content='" ; if (message.getContentType() == "amqp/map") { - Variant::Map map; - decode(message, map); - std::cout << map; + std::cout << message.getContentObject().asMap(); } else { std::cout << message.getContent(); } @@ -106,7 +104,7 @@ int main(int argc, char** argv) break; } receiver.close(); - session.close(); + session.close(); connection.close(); return 0; } catch(const std::exception& error) { @@ -114,5 +112,5 @@ int main(int argc, char** argv) connection.close(); } } - return 1; + return 1; } diff --git a/qpid/cpp/examples/messaging/map_receiver.cpp b/qpid/cpp/examples/messaging/map_receiver.cpp index 081f7394a8..96bc76b821 100644 --- a/qpid/cpp/examples/messaging/map_receiver.cpp +++ b/qpid/cpp/examples/messaging/map_receiver.cpp @@ -39,15 +39,13 @@ int main(int argc, char** argv) { const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; const char* address = argc>2 ? argv[2] : "message_queue; {create: always}"; std::string connectionOptions = argc > 3 ? argv[3] : ""; - + Connection connection(url, connectionOptions); try { connection.open(); Session session = connection.createSession(); Receiver receiver = session.createReceiver(address); - Variant::Map content; - decode(receiver.fetch(), content); - std::cout << content << std::endl; + std::cout << receiver.fetch().getContentObject() << std::endl; session.acknowledge(); receiver.close(); connection.close(); @@ -56,5 +54,5 @@ int main(int argc, char** argv) { std::cout << error.what() << std::endl; connection.close(); } - return 1; + return 1; } diff --git a/qpid/cpp/examples/messaging/map_sender.cpp b/qpid/cpp/examples/messaging/map_sender.cpp index 8ce3e1d8ec..81ac7320d8 100644 --- a/qpid/cpp/examples/messaging/map_sender.cpp +++ b/qpid/cpp/examples/messaging/map_sender.cpp @@ -39,7 +39,7 @@ int main(int argc, char** argv) { const char* url = argc>1 ? argv[1] : "amqp:tcp:127.0.0.1:5672"; const char* address = argc>2 ? argv[2] : "message_queue; {create: always}"; std::string connectionOptions = argc > 3 ? argv[3] : ""; - + Connection connection(url, connectionOptions); try { connection.open(); @@ -57,8 +57,8 @@ int main(int argc, char** argv) { colours.push_back(Variant("white")); content["colours"] = colours; content["uuid"] = Uuid(true); - encode(content, message); - + message.setContentObject(content); + sender.send(message, true); connection.close(); diff --git a/qpid/cpp/examples/messaging/spout.cpp b/qpid/cpp/examples/messaging/spout.cpp index 72fcdc7c65..e80b434b3e 100644 --- a/qpid/cpp/examples/messaging/spout.cpp +++ b/qpid/cpp/examples/messaging/spout.cpp @@ -145,7 +145,7 @@ int main(int argc, char** argv) if (options.entries.size()) { Variant::Map content; options.setEntries(content); - encode(content, message); + message.getContentObject() = content; } else if (options.content.size()) { message.setContent(options.content); message.setContentType("text/plain"); |
