summaryrefslogtreecommitdiff
path: root/python/examples/xml-exchange
diff options
context:
space:
mode:
Diffstat (limited to 'python/examples/xml-exchange')
-rwxr-xr-xpython/examples/xml-exchange/declare_queues.py90
-rwxr-xr-xpython/examples/xml-exchange/listener.py105
-rw-r--r--python/examples/xml-exchange/verify22
-rw-r--r--python/examples/xml-exchange/verify.in15
-rwxr-xr-xpython/examples/xml-exchange/xml_consumer.py96
-rwxr-xr-xpython/examples/xml-exchange/xml_producer.py92
6 files changed, 0 insertions, 420 deletions
diff --git a/python/examples/xml-exchange/declare_queues.py b/python/examples/xml-exchange/declare_queues.py
deleted file mode 100755
index ca40af5dc5..0000000000
--- a/python/examples/xml-exchange/declare_queues.py
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/usr/bin/env python
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-"""
- declare_queues.py
-
- Creates and binds a queue on an AMQP direct exchange.
-
- All messages using the routing key "routing_key" are
- sent to the queue named "message_queue".
-"""
-
-import qpid
-import sys
-import os
-from qpid.util import connect
-from qpid.connection import Connection
-from qpid.datatypes import Message, RangedSet, uuid4
-from qpid.queue import Empty
-
-#----- Initialization -----------------------------------
-
-
-# Set parameters for login
-
-host="127.0.0.1"
-port=5672
-user="guest"
-password="guest"
-
-# If an alternate host or port has been specified, use that instead
-# (this is used in our unit tests)
-if len(sys.argv) > 1 :
- host=sys.argv[1]
-if len(sys.argv) > 2 :
- port=int(sys.argv[2])
-
-# Create a connection.
-socket = connect(host, port)
-connection = Connection (sock=socket, username=user, password=password)
-connection.start()
-session = connection.session(str(uuid4()))
-
-#----- Create a queue -------------------------------------
-
-# queue_declare() creates an AMQP queue, which is held
-# on the broker. Published messages are sent to the AMQP queue,
-# from which messages are delivered to consumers.
-#
-# queue_bind() determines which messages are routed to a queue.
-# Route all messages with the routing key "routing_key" to
-# the AMQP queue named "message_queue".
-
-session.exchange_declare(exchange="xml", type="xml")
-session.queue_declare(queue="message_queue")
-
-binding = {}
-binding["xquery"] = """
- 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 """
-
-
-session.exchange_bind(exchange="xml", queue="message_queue", binding_key="weather", arguments=binding)
-
-
-#----- Cleanup ---------------------------------------------
-
-session.close()
-
-
diff --git a/python/examples/xml-exchange/listener.py b/python/examples/xml-exchange/listener.py
deleted file mode 100755
index a56f5d6018..0000000000
--- a/python/examples/xml-exchange/listener.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/env python
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-"""
- listener.py
-
- This AMQP client reads messages from a message
- queue named "message_queue". It is implemented
- as a message listener.
-"""
-
-
-import qpid
-import sys
-import os
-from qpid.util import connect
-from qpid.connection import Connection
-from qpid.datatypes import Message, RangedSet, uuid4
-from qpid.queue import Empty
-
-#
-
-from time import sleep
-
-
-#----- Message Receive Handler -----------------------------
-class Receiver:
- def __init__ (self):
- self.finalReceived = False
-
- def isFinal (self):
- return self.finalReceived
-
- def Handler (self, message):
- content = message.body
- session.message_accept(RangedSet(message.id))
- print content
-
-#----- Initialization --------------------------------------
-
-# Set parameters for login
-
-host="127.0.0.1"
-port=5672
-user="guest"
-password="guest"
-
-# If an alternate host or port has been specified, use that instead
-# (this is used in our unit tests)
-if len(sys.argv) > 1 :
- host=sys.argv[1]
-if len(sys.argv) > 2 :
- port=int(sys.argv[2])
-
-# Create a connection.
-socket = connect(host, port)
-connection = Connection (sock=socket, username=user, password=password)
-connection.start()
-session = connection.session(str(uuid4()))
-
-#----- Read from queue --------------------------------------------
-
-# Now let's create a local client queue and tell it to read
-# incoming messages.
-
-# The consumer tag identifies the client-side queue.
-
-local_queue_name = "local_queue"
-local_queue = session.incoming(local_queue_name)
-
-# Call message_subscribe() to tell the broker to deliver messages
-# from the AMQP queue to this local client queue. The broker will
-# start delivering messages as soon as local_queue.start() is called.
-
-session.message_subscribe(queue="message_queue", destination=local_queue_name)
-local_queue.start()
-
-receiver = Receiver ()
-local_queue.listen (receiver.Handler)
-
-sleep (10)
-
-
-#----- Cleanup ------------------------------------------------
-
-# Clean up before exiting so there are no open threads.
-#
-
-session.close()
diff --git a/python/examples/xml-exchange/verify b/python/examples/xml-exchange/verify
deleted file mode 100644
index a93a32dc90..0000000000
--- a/python/examples/xml-exchange/verify
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-# See https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid/bin/verify
-clients ./declare_queues.py ./xml_producer.py ./xml_consumer.py
-outputs ./declare_queues.py.out ./xml_producer.py.out ./xml_consumer.py.out
diff --git a/python/examples/xml-exchange/verify.in b/python/examples/xml-exchange/verify.in
deleted file mode 100644
index e5b9909408..0000000000
--- a/python/examples/xml-exchange/verify.in
+++ /dev/null
@@ -1,15 +0,0 @@
-==== declare_queues.py.out
-==== xml_producer.py.out
-<weather><station>Raleigh-Durham International Airport (KRDU)</station><wind_speed_mph>0</wind_speed_mph><temperature_f>30</temperature_f><dewpoint>35</dewpoint></weather>
-<weather><station>New Bern, Craven County Regional Airport (KEWN)</station><wind_speed_mph>2</wind_speed_mph><temperature_f>40</temperature_f><dewpoint>40</dewpoint></weather>
-<weather><station>Boone, Watauga County Hospital Heliport (KTNB)</station><wind_speed_mph>5</wind_speed_mph><temperature_f>50</temperature_f><dewpoint>45</dewpoint></weather>
-<weather><station>Hatteras, Mitchell Field (KHSE)</station><wind_speed_mph>10</wind_speed_mph><temperature_f>60</temperature_f><dewpoint>50</dewpoint></weather>
-<weather><station>Raleigh-Durham International Airport (KRDU)</station><wind_speed_mph>16</wind_speed_mph><temperature_f>70</temperature_f><dewpoint>35</dewpoint></weather>
-<weather><station>New Bern, Craven County Regional Airport (KEWN)</station><wind_speed_mph>22</wind_speed_mph><temperature_f>80</temperature_f><dewpoint>40</dewpoint></weather>
-<weather><station>Boone, Watauga County Hospital Heliport (KTNB)</station><wind_speed_mph>28</wind_speed_mph><temperature_f>90</temperature_f><dewpoint>45</dewpoint></weather>
-<weather><station>Hatteras, Mitchell Field (KHSE)</station><wind_speed_mph>35</wind_speed_mph><temperature_f>100</temperature_f><dewpoint>50</dewpoint></weather>
-<weather><station>Raleigh-Durham International Airport (KRDU)</station><wind_speed_mph>42</wind_speed_mph><temperature_f>30</temperature_f><dewpoint>35</dewpoint></weather>
-<weather><station>New Bern, Craven County Regional Airport (KEWN)</station><wind_speed_mph>51</wind_speed_mph><temperature_f>40</temperature_f><dewpoint>40</dewpoint></weather>
-==== xml_consumer.py.out
-<weather><station>Raleigh-Durham International Airport (KRDU)</station><wind_speed_mph>16</wind_speed_mph><temperature_f>70</temperature_f><dewpoint>35</dewpoint></weather>
-No more messages!
diff --git a/python/examples/xml-exchange/xml_consumer.py b/python/examples/xml-exchange/xml_consumer.py
deleted file mode 100755
index cd89110b05..0000000000
--- a/python/examples/xml-exchange/xml_consumer.py
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/usr/bin/env python
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-"""
- direct_consumer.py
-
- This AMQP client reads messages from a message
- queue named "message_queue".
-"""
-
-import qpid
-import sys
-import os
-from random import randint
-from qpid.util import connect
-from qpid.connection import Connection
-from qpid.datatypes import Message, RangedSet, uuid4
-from qpid.queue import Empty
-
-
-#----- Initialization --------------------------------------
-
-# Set parameters for login
-
-host="127.0.0.1"
-port=5672
-user="guest"
-password="guest"
-
-# If an alternate host or port has been specified, use that instead
-# (this is used in our unit tests)
-if len(sys.argv) > 1 :
- host=sys.argv[1]
-if len(sys.argv) > 2 :
- port=int(sys.argv[2])
-
-# Create a connection.
-socket = connect(host, port)
-connection = Connection (sock=socket, username=user, password=password)
-connection.start()
-session = connection.session(str(uuid4()))
-
-
-#----- Read from queue --------------------------------------------
-
-# Now let's create a local client queue and tell it to read
-# incoming messages.
-
-# The consumer tag identifies the client-side queue.
-
-local_queue_name = "local_queue"
-local_queue = session.incoming(local_queue_name)
-
-# Call message_consume() to tell the broker to deliver messages
-# from the AMQP queue to this local client queue. The broker will
-# start delivering messages as soon as local_queue.start() is called.
-
-session.message_subscribe(queue="message_queue", destination=local_queue_name)
-local_queue.start()
-
-# Initialize 'final' and 'content', variables used to identify the last message.
-
-message = None
-while True:
- try:
- message = local_queue.get(timeout=10)
- session.message_accept(RangedSet(message.id))
- content = message.body
- print content
- except Empty:
- print "No more messages!"
- break
-
-
-#----- Cleanup ------------------------------------------------
-
-# Clean up before exiting so there are no open threads.
-#
-
-session.close()
diff --git a/python/examples/xml-exchange/xml_producer.py b/python/examples/xml-exchange/xml_producer.py
deleted file mode 100755
index fa97cab4e1..0000000000
--- a/python/examples/xml-exchange/xml_producer.py
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/usr/bin/env python
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-"""
- xml_producer.py
-
- Publishes messages to an XML exchange, using
- the routing key "weather"
-"""
-
-
-import qpid
-import sys
-import os
-from qpid.util import connect
-from qpid.connection import Connection
-from qpid.datatypes import Message, RangedSet, uuid4
-from qpid.queue import Empty
-
-#----- Functions ----------------------------------------
-
-# Data for weather reports
-
-station = ("Raleigh-Durham International Airport (KRDU)",
- "New Bern, Craven County Regional Airport (KEWN)",
- "Boone, Watauga County Hospital Heliport (KTNB)",
- "Hatteras, Mitchell Field (KHSE)")
-wind_speed_mph = ( 0, 2, 5, 10, 16, 22, 28, 35, 42, 51, 61, 70, 80 )
-temperature_f = ( 30, 40, 50, 60, 70, 80, 90, 100 )
-dewpoint = ( 35, 40, 45, 50 )
-
-def pick_one(list, i):
- return str( list [ i % len(list)] )
-
-def report(i):
- return "<weather>" + "<station>" + pick_one(station,i)+ "</station>" + "<wind_speed_mph>" + pick_one(wind_speed_mph,i) + "</wind_speed_mph>" + "<temperature_f>" + pick_one(temperature_f,i) + "</temperature_f>" + "<dewpoint>" + pick_one(dewpoint,i) + "</dewpoint>" + "</weather>"
-
-
-#----- Initialization -----------------------------------
-
-# Set parameters for login
-
-host="127.0.0.1"
-port=5672
-user="guest"
-password="guest"
-
-# If an alternate host or port has been specified, use that instead
-# (this is used in our unit tests)
-if len(sys.argv) > 1 :
- host=sys.argv[1]
-if len(sys.argv) > 2 :
- port=int(sys.argv[2])
-
-# Create a connection.
-socket = connect(host, port)
-connection = Connection (sock=socket, username=user, password=password)
-connection.start()
-session = connection.session(str(uuid4()))
-
-#----- Publish some messages ------------------------------
-
-# Create some messages and put them on the broker.
-
-props = session.delivery_properties(routing_key="weather")
-
-for i in range(10):
- print report(i)
- session.message_transfer(destination="xml", message=Message(props, report(i)))
-
-
-#----- Cleanup --------------------------------------------
-
-# Clean up before exiting so there are no open threads.
-
-session.close()