From 38500cf6977d7959da0f67eeb090a5cf7777cba4 Mon Sep 17 00:00:00 2001 From: Jonathan Robie Date: Fri, 7 May 2010 19:00:51 +0000 Subject: Changes from today's discussion on map type tables. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@942181 13f79535-47bb-0310-9956-ffa450edef68 --- doc/book/src/Programming-In-Apache-Qpid.xml | 298 ++++++++++++++-------------- 1 file changed, 152 insertions(+), 146 deletions(-) (limited to 'doc/book/src/Programming-In-Apache-Qpid.xml') diff --git a/doc/book/src/Programming-In-Apache-Qpid.xml b/doc/book/src/Programming-In-Apache-Qpid.xml index d0abec1266..ea00774996 100644 --- a/doc/book/src/Programming-In-Apache-Qpid.xml +++ b/doc/book/src/Programming-In-Apache-Qpid.xml @@ -1424,6 +1424,13 @@ std::cout << request.getContent() << " -> " << response.getContent() << std::end portable datatypes. + + Because of the differences in type systems among + languages, the simplest way to provide portable messages is to + rely on maps, lists, strings, 64 bit signed integers, and + doubles for messages that need to be exchanged across languages + and platforms. +
Qpid Maps in Python @@ -1465,12 +1472,10 @@ sender.send(message) boolboolboolean - integerintegerlong - shortintegershort + integerlonglong longlonglong - floatfloatfloat floatdoubledouble - stringunicodejava.lang.String + unicodestringjava.lang.String uuidqpid::types::Uuidjava.util.UUID dictVariant::Mapjava.util.Map listVariant::Listjava.util.List @@ -1559,16 +1564,16 @@ sender.send(message, true); boolboolboolean - unsigned charstringchar - unsigned short intintegershort - unsigned intintegerinteger - unsigned longintegerlong - charstringchar - shortintegershort - intintegerinteger - longlonglong + unsigned charunicodechar + unsigned short intinteger | longshort + unsigned intinteger | longinteger + unsigned longinteger | longlong + charunicodechar + shortinteger | longshort + intinteger | longinteger + longinteger | longlong floatfloatfloat - double, long doublefloatdouble + doublefloatdouble stringunicodejava.lang.String qpid::types::Uuiduuidjava.util.UUID Variant::Mapdictjava.util.Map @@ -1579,130 +1584,8 @@ sender.send(message, true);
- -
- XML Exchange - - The XML Exchange is an AMQP 0-10 custom exchange provided by the Apache Qpid C++ broker. It allows messages to be filtered using XQuery; queries can address either message properties or XML content in the body of the message. - - An instance of the XML Exchange must be added before it can be used: - - -$ qpid-config add exchange xml xml - - - When using the XML exchange, a sender's address string must provide a subject, e.g. xml/weather. - - If a receiver that is using the XML exchange also provides a subject, it receives messages if the subject exactly matches a message's subject. - - - When using the XML Exchange, a receiver normally provides an XQuery as an x-binding argument. If the query contains a context item (a path starting with .), then it is applied to the content of the message, which must be well-formed XML. For instance, ./weather is a valid XQuery, which matches any message in which the root element is named weather. Here is an address string that contains this query: - - - - Note that each x-binding is created in addition to any other bindings that may exist, and each x-binding must include the exchange name, the key, and the xquery. If you specify the subject in the address string (e.g. xml/weather; link ...), it creates a binding that is used in addition to the x-bindings; the binding created for the subject matches any message whose subject is weather, the binding created for the x-binding matches any message that satisfies the query, i.e. any message with a root element named weather. - - - - The XML Exchange can also be used to query message properties by declaring an external variable with the same name as each property that is to be queried. The following XQuery queries the control property, as well as the content of the message: - - - - If the XQuery addresses message content, and the message is not well-formed XML, the message will not be received. If the XQuery does not query message content, the message need not contain XML. - - - - Using the XML Exchange with <command>drain</command> - - The following shows the arguments used with drain to retrieve messages whose root element is named weather: - - - - - - Using the XML Exchange with C++ - - In C++, it is convenient to place an XQuery in a string, and use a stringstream to add the query to the template for an address string that specifies an x-binding. - - 50" - " and $w/temperature_f - $w/dewpoint > 5" - " and $w/wind_speed_mph > 7" - " and $w/wind_speed_mph < 20"; - -stringstream address; - -address << "xml; {" - " link: { " - " x-bindings: [{ exchange: xml, key: weather, arguments: { xquery:\"" - << query - << "\"} }] " - " } " - "}"; - - -Receiver receiver = session.createReceiver(address.str()); -Message response = receiver.fetch(); -session.acknowledge(); -std::cout << response.getContent() << std::endl; - - ]]> - - - - - Using the XML Exchange with Python - - In Python, it is often convenient to place the query in - a separate string, and use the repr() value of the query - string in an address template string. - - 50 - and $w/temperature_f - $w/dewpoint > 5 - and $w/wind_speed_mph > 7 - and $w/wind_speed_mph < 20 """ - - address = """ - xml; { - link: { - x-bindings: [{ exchange: xml, key: weather, arguments: { xquery: %r} }] - } - } - """ % query - - receiver = session.receiver(address) - -# Retrieve matching message from the receiver and print it - - message = receiver.fetch(timeout=1) - print message.content - session.acknowledge() - ]]> - - -
- -
+
+
Performance Clients can often be made significantly faster by batching acknowledgements and setting the capacity of receivers to allow prefetch. @@ -1835,7 +1718,129 @@ else -
+
+ XML Exchange + + The XML Exchange is an AMQP 0-10 custom exchange provided by the Apache Qpid C++ broker. It allows messages to be filtered using XQuery; queries can address either message properties or XML content in the body of the message. + + An instance of the XML Exchange must be added before it can be used: + + +$ qpid-config add exchange xml xml + + + When using the XML exchange, a sender's address string must provide a subject, e.g. xml/weather. + + If a receiver that is using the XML exchange also provides a subject, it receives messages if the subject exactly matches a message's subject. + + + When using the XML Exchange, a receiver normally provides an XQuery as an x-binding argument. If the query contains a context item (a path starting with .), then it is applied to the content of the message, which must be well-formed XML. For instance, ./weather is a valid XQuery, which matches any message in which the root element is named weather. Here is an address string that contains this query: + + + + Note that each x-binding is created in addition to any other bindings that may exist, and each x-binding must include the exchange name, the key, and the xquery. If you specify the subject in the address string (e.g. xml/weather; link ...), it creates a binding that is used in addition to the x-bindings; the binding created for the subject matches any message whose subject is weather, the binding created for the x-binding matches any message that satisfies the query, i.e. any message with a root element named weather. + + + + The XML Exchange can also be used to query message properties by declaring an external variable with the same name as each property that is to be queried. The following XQuery queries the control property, as well as the content of the message: + + + + If the XQuery addresses message content, and the message is not well-formed XML, the message will not be received. If the XQuery does not query message content, the message need not contain XML. + + + + Using the XML Exchange with <command>drain</command> + + The following shows the arguments used with drain to retrieve messages whose root element is named weather: + + + + + + Using the XML Exchange with C++ + + In C++, it is convenient to place an XQuery in a string, and use a stringstream to add the query to the template for an address string that specifies an x-binding. + + 50" + " and $w/temperature_f - $w/dewpoint > 5" + " and $w/wind_speed_mph > 7" + " and $w/wind_speed_mph < 20"; + +stringstream address; + +address << "xml; {" + " link: { " + " x-bindings: [{ exchange: xml, key: weather, arguments: { xquery:\"" + << query + << "\"} }] " + " } " + "}"; + + +Receiver receiver = session.createReceiver(address.str()); +Message response = receiver.fetch(); +session.acknowledge(); +std::cout << response.getContent() << std::endl; + + ]]> + + + + + Using the XML Exchange with Python + + In Python, it is often convenient to place the query in + a separate string, and use the repr() value of the query + string in an address template string. + + 50 + and $w/temperature_f - $w/dewpoint > 5 + and $w/wind_speed_mph > 7 + and $w/wind_speed_mph < 20 """ + + address = """ + xml; { + link: { + x-bindings: [{ exchange: xml, key: weather, arguments: { xquery: %r} }] + } + } + """ % query + + receiver = session.receiver(address) + +# Retrieve matching message from the receiver and print it + + message = receiver.fetch(timeout=1) + print message.content + session.acknowledge() + ]]> + + +
+ +
The AMQP 0-10 mapping @@ -2389,11 +2394,12 @@ amqp://guest:guest@test/test?sync_ack='true' For secure applications, we suggest CRAM-MD5, DIGEST-MD5, or GSSAPI. The ANONYMOUS method is not secure. The PLAIN method is secure only when used - together with SSL. - For Kerberos, sasl_mechs must be set to GSSAPI, - sasl_protocol must be set to the principal for the qpidd broker, e.g. qpidd/, and - sasl_server must be set to the host for the SASL server, e.g. sasl.com. - SASL External is supported using SSL certification, e.g. + together with SSL. For Kerberos, sasl_mechs must be + set to GSSAPI, sasl_protocol must be set to the + principal for the qpidd broker, e.g. qpidd/, and + sasl_server must be set to the host for the SASL + server, e.g. sasl.com. SASL External is supported + using SSL certification, e.g. ssl='true'&sasl_mechs='EXTERNAL' @@ -2666,12 +2672,12 @@ producer.send(m); booleanboolbool - charstringThe Python string will contain one Unicode characterint??? Java char is 16-bit + charunicodeThe Python string will contain one Unicode characterint shortintegershort integerintegerint - longlong integerlong + longintegerlong floatfloatfloat - doublefloatdouble, long double + doublefloatdouble java.lang.Stringunicodestd::string java.util.UUIDuuidqpid::types::Uuid java.util.MapdictVariant::Map -- cgit v1.2.1