diff options
| author | Ask Solem <askh@opera.com> | 2010-12-01 12:28:10 +0100 |
|---|---|---|
| committer | Ask Solem <askh@opera.com> | 2010-12-01 12:28:10 +0100 |
| commit | b6d679fe34d8e5346dd1e00db5ce7613324f074d (patch) | |
| tree | c05e4c494239d34da95af73431d49a884acb49bf /examples | |
| parent | 8ebbbd3ac8849d002c7f00adc7371bed55c80840 (diff) | |
| download | kombu-b6d679fe34d8e5346dd1e00db5ce7613324f074d.tar.gz | |
Added SimpleQueue examples: examples/simple_receive.py, simple_send.py
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/complete_receive.py (renamed from examples/demo_receive.py) | 0 | ||||
| -rw-r--r-- | examples/complete_send.py (renamed from examples/demo_send.py) | 0 | ||||
| -rw-r--r-- | examples/simple_receive.py | 24 | ||||
| -rw-r--r-- | examples/simple_send.py | 27 |
4 files changed, 51 insertions, 0 deletions
diff --git a/examples/demo_receive.py b/examples/complete_receive.py index bf618e46..bf618e46 100644 --- a/examples/demo_receive.py +++ b/examples/complete_receive.py diff --git a/examples/demo_send.py b/examples/complete_send.py index 11790590..11790590 100644 --- a/examples/demo_send.py +++ b/examples/complete_send.py diff --git a/examples/simple_receive.py b/examples/simple_receive.py new file mode 100644 index 00000000..276d30cf --- /dev/null +++ b/examples/simple_receive.py @@ -0,0 +1,24 @@ +""" +Example receiving a message using the SimpleQueue interface. +""" + +from kombu import BrokerConnection + +#: Create connection +#: If hostname, userid, password and virtual_host is not specified +#: the values below are the default, but listed here so it can +#: be easily changed. +connection = BrokerConnection(hostname="localhost", + userid="guest", + password="guest", + virtual_host="/") + + +#: SimpleQueue mimics the interface of the Python Queue module. +#: First argument can either be a queue name or a kombu.Queue object. +#: If a name, then the queue will be declared with the name as the queue +#: name, exchange name and routing key. +queue = connection.SimpleQueue("kombu_demo") +message = queue.get(block=True, timeout=10) +message.ack() +print(message.payload) diff --git a/examples/simple_send.py b/examples/simple_send.py new file mode 100644 index 00000000..11a5e330 --- /dev/null +++ b/examples/simple_send.py @@ -0,0 +1,27 @@ +""" + +Example that sends a single message and exits using the simple interface. + +You can use `simple_receive.py` (or `complete_receive.py`) to receive the +message sent. + +""" + +from kombu import BrokerConnection + +#: Create connection +#: If hostname, userid, password and virtual_host is not specified +#: the values below are the default, but listed here so it can +#: be easily changed. +connection = BrokerConnection(hostname="localhost", + userid="guest", + password="guest", + virtual_host="/") + + +#: SimpleQueue mimics the interface of the Python Queue module. +#: First argument can either be a queue name or a kombu.Queue object. +#: If a name, then the queue will be declared with the name as the queue +#: name, exchange name and routing key. +queue = connection.SimpleQueue("kombu_demo") +queue.put({"hello": "world"}, serializer="json", compression="zlib") |
