AMQP layer for communicating with the ESB.
Project description
Client side implementation of an ESB via Amazon SQS.
Simple Usage
uri = 'sqs://LOGIN:PASSWORD@' transport = { 'region': 'eu-west-1', 'exchange': 'swarm', 'queue_name_prefix': 'dev-%(hostname)s-', 'office_hours': False, 'use_priorities': True, 'priorities': ['low', 'high'] } queues = { 'my_queue': { 'route': 'my.queue.route', # Specific route 'sleep': 60, # Seconds before next call to SQS 'visibility': 1800, # Visibility message in queue 'wait': 10 # Long polling seconds }, 'my_second_queue': {} # Will be automaticaly filled/completed } bus = AMQP(uri, transport, queues) bus.connect() # We purge a known queue bus.purge_queue('my_queue') # Now we add a new queue on the fly bus.register_queue('new_queue', {'wait': 20}) bus.close()
Using as a producer
with AMQP(uri, transport, queues) as producer: producer.publish( 'my_queue', {'id': 42}, 1 # Optional, specify 'high' priority queue )
Using as a consumer
def print_routing_key(body, message): id_ = body['id'] rk = message.delivery_info['routing_key'] print("[x] %r:%r" % (rk, id_)) def ack_message(body, message): message.ack() def error_handler(body, message): raise ValueError('Error while processing message') with AMQP(uri, transport, queues) as consumer: consumer.consume( 'my_queue', [print_routing_key, ack_message], error_handler )
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
swarm-bus-3.1.tar.gz
(5.1 kB
view details)
Built Distribution
File details
Details for the file swarm-bus-3.1.tar.gz
.
File metadata
- Download URL: swarm-bus-3.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/36.5.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/2.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8424b6f0bc9e062458f6d01f5187c091591842c4a6756626561229069e13f796 |
|
MD5 | e482eaeb9ab4e4786db781244851cb18 |
|
BLAKE2b-256 | 27e7b55b97c34a2d553a212eb699c9c5e4ed68a05ee502b474904334ea708afb |
File details
Details for the file swarm_bus-3.1-py2-none-any.whl
.
File metadata
- Download URL: swarm_bus-3.1-py2-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/36.5.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/2.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d06f536745419b3ff5a9b1777cb6f6b271e4961efc4ef79a0a686ae39f41be15 |
|
MD5 | ddd725533a6153102e61ac819bc90f92 |
|
BLAKE2b-256 | cda465fb196428f3ca6a95a2e3d93d7d97fbf2b353467d8edc0b132242953732 |