declare_queues.py creates a queue on the broker, declares an XML Exchange, subscribes the queue to the XML Exchange using an XQuery in the binding, then exits.
xml_producer.py publishes messages to the XML Exchange.
xml_consumer.py reads messages from the queue.
listener.py reads messages from the queue using a listener.
/usr/share/doc/rhm-0.3/python/xml-exchange. To run these programs, do the following:
$ ps -eaf | grep qpidd
qpidd process in the output of the above command. If no broker is running, see the instructions in Chapter 3, Installing MRG Messaging.
declare_queues.py, as follows:
$ python declare_queues.py
xml exchange using the routing key weather are sent to the queue named message_queue if they satisfy the conditions specified in the following XQuery, which is used in the binding:
let $w := ./weather
return $w/station = 'Raleigh-Durham International Airport (KRDU)'
and $w/temperature_f > 50
and $w/temperature_f - $w/dewpoint > 5
and $w/wind_speed_mph > 7
and $w/wind_speed_mph < 20
xml exchange by running xml_producer.py, as follows:
$ python xml_producer.py
<weather>
<station>Raleigh-Durham International Airport (KRDU)</station>
<wind_speed_mph>16</wind_speed_mph>
<temperature_f>70</temperature_f>
<dewpoint>35</dewpoint>
</weather>
direct_consumer.py or listener.py, as follows:
$ python xml_consumer.py
$ python listener.py
<weather><station>Raleigh-Durham International Airport (KRDU)</station><wind_speed_mph>16</wind_speed_mph><temperature_f>70</temperature_f><dewpoint>35</dewpoint></weather>