Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
4.11.4. Subscribe to the XML Exchange
The following code subscribes to an XML exchange
myxml by creating a queue xmlq and binding it to the exchange with an XQuery.
AMQP 0-10
- Python
rxXML = ssn.receiver("myxmlq; {create:always, link: { x-bindings: [{exchange:myxml, key:weather, arguments:{xquery:'./weather'} }]}}")rxXML = ssn.receiver("myxmlq; {create:always, link: { x-bindings: [{exchange:myxml, key:weather, arguments:{xquery:'./weather'} }]}}")Copy to Clipboard Copied! Toggle word wrap Toggle overflow
AMQP 1.0
- C++
Receiver rxXML = ssn.createReceiver("myxml/weather; {link: {name:myxmlq, filter:{name:myfilter, descriptor:'apache.org:query-filter:string', value:'./weather'}}}");Receiver rxXML = ssn.createReceiver("myxml/weather; {link: {name:myxmlq, filter:{name:myfilter, descriptor:'apache.org:query-filter:string', value:'./weather'}}}");Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The XQuery
./weather will match any messages whose body content has the root XML element <weather>.
Note the use of the
key argument for x-bindings. This ensures that the binding has a unique name, allowing it to be deleted and updated by name, and ensuring that it is not accidentally updated, as might be the case if it were anonymous in the namespace of the exchange.
The following code demonstrates using the XML exchange with a more complex XQuery (using AMQP 0-10 addressing):
- Python
Copy to Clipboard Copied! Toggle word wrap Toggle overflow