From bc49e03d63283771b8a642c39bc97e63f5b99bc4 Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Thu, 6 May 2010 23:13:17 +0000 Subject: Added tables and programming examples for map messages in C++, Python, and Java. This is very, very rough, don't build from this, but it will be easy to fix these sections tomorrow morning. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@941968 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/doc/book/src/Programming-In-Apache-Qpid.xml | 310 ++++++++++++++++++++++- 1 file changed, 298 insertions(+), 12 deletions(-) diff --git a/qpid/doc/book/src/Programming-In-Apache-Qpid.xml b/qpid/doc/book/src/Programming-In-Apache-Qpid.xml index c874e68199..a8b552617b 100644 --- a/qpid/doc/book/src/Programming-In-Apache-Qpid.xml +++ b/qpid/doc/book/src/Programming-In-Apache-Qpid.xml @@ -1117,12 +1117,15 @@ options := map -
+
Logging - The Qpidd broker and C++ clients can both use environment - variables to enable logging. Use QPID_LOG_ENABLE to set the - level of logging you are interested in (trace, debug, info, - notice, warning, error, or critical): +########### +
+ Logging in C++ + The Qpidd broker and C++ clients can both use environment + variables to enable logging. Use QPID_LOG_ENABLE to set the + level of logging you are interested in (trace, debug, info, + notice, warning, error, or critical): $ export QPID_LOG_ENABLE="warning+" @@ -1136,8 +1139,29 @@ $ export QPID_LOG_ENABLE="warning+" export QPID_LOG_TO_FILE="/tmp/myclient.out" -
- +
+ +
+ Logging in Python + + The Python client library supports logging using the standard Python logging module. The easiest way to do logging is to use the basicConfig(), which reports all warnings and errors: + + +from logging import basicConfig +basicConfig() + + + Qpidd also provides a convenience method that makes it easy to specify the level of logging desired. For instance, the following code enables logging at the DEBUG level: + + +from qpid.log import enable, DEBUG +enable("qpid.messaging.io", DEBUG) + + + For more information on Python logging, see http://docs.python.org/lib/node425.html. For more information on Qpid logging, use $ pydoc qpid.log. + +
+
@@ -1361,13 +1385,183 @@ std::cout << request.getContent() << " -> " << response.getContent() << std::end -->
+
+ Maps in Messages + + Many messaging applications need to exchange data across + languages and platforms, using the native datatypes of each + programming language. AMQP provides a set of portable datatypes, + but does not directly support a set of named type/value + pairs. Java JMS provides the MapMessage + interface, which allows sets of named type/value pairs, but does + not provide a set of portable datatypes. The Qpid Messaging API + supports maps, analogous to Java JMS + MapMessage, using the datatypes that are + most convenient in each language. For simple datatypes, it + simply uses the equivalent datatype in each language. For + complex datatypes, it follows the conventions of each language. + - +
+ Qpid Maps in Python + + In Python, Qpid supports the dict and list types directly in message content. + + + Sending Qpid Maps in Python + + + + + The following table shows the datatypes that can be sent in a Python map message, + and the corresponding datatypes that will be received by clients in or . + + + + Python Datatypes in Maps + + + + Python Datatype + → C++ + → Java + + + + boolboolboolean + integerintegerlong + shortintegershort + longlonglong + floatfloatfloat + floatdoubledouble + stringunicodejava.lang.String + uuidqpid::types::Uuidjava.util.UUID + dictVariant::Mapjava.util.Map + listVariant::Listjava.util.List + + +
+ +
+ + + + +
+ ### C++ ### + + The following table shows the datatypes that can be sent + in a C++ map message, and the corresponding datatypes that + will be received by clients in #### or . + + + + + + + + C++ Datatypes in Maps + + + + C++ Datatype + → Python + → Java + + + + boolboolboolean + unsigned charstringchar + unsigned short intintegershort + unsigned intintegerinteger + unsigned longintegerlong + charstringchar + shortintegershort + intintegerinteger + longlonglong + floatfloatfloat + double, long doublefloatdouble + stringunicodejava.lang.String + qpid::types::Uuiduuidjava.util.UUID + Variant::Mapdictjava.util.Map + Variant::Listlistjava.util.List + + +
+
+ + +
XML Exchange @@ -2377,6 +2571,98 @@ amqp://guest:guest@test/test?sync_ack='true'
+
+ JMS MapMessage Types + + Qpid supports the Java JMS MapMessage interface, which provides support for maps in messages. + + + + + Map Messages in Java JMS + colors = new ArrayList(); +colors.add("red"); +colors.add("green"); +colors.add("white"); +m.setObject("colours", colors); + +Map dimensions = new HashMap(); +dimensions.put("length",10.2); +dimensions.put("width",5.1); +dimensions.put("depth",2.0); +m.setObject("dimensions",dimensions); + +List> parts = new ArrayList>(); +parts.add(Arrays.asList(new Integer[] {1,2,5})); +parts.add(Arrays.asList(new Integer[] {8,2,5})); +m.setObject("parts", parts); + +Map specs = new HashMap(); +specs.put("colours", colors); +specs.put("dimensions", dimensions); +specs.put("parts", parts); +m.setObject("specs",specs); + +producer.send(m); + ]]> + + The following table shows the datatypes that can be sent in a MapMessage, and the corresponding datatypes that will be received by clients in or . + + + + Java Datatypes in Maps + + + + Java Datatype + → Python + → C++ + + + + booleanboolbool + charstringThe Python string will contain one Unicode characterint??? Java char is 16-bit + shortintegershort + integerintegerint + longlong integerlong + floatfloatfloat + doublefloatdouble, long double + java.lang.Stringunicodestd::string + java.util.UUIDuuidqpid::types::Uuid + java.util.MapdictVariant::Map + java.util.ListlistVariant::List + + +
+ +
+
Java JMS Selector Syntax The AMQP Java JMS Messaging Client supports the following syntax for JMS selectors. -- cgit v1.2.1