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-4.0.tar.gz
(7.2 kB
view details)
Built Distribution
File details
Details for the file swarm-bus-4.0.tar.gz
.
File metadata
- Download URL: swarm-bus-4.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39619c8f1dedf8adaa9d2bb493769da13a01f3f06540a8667a6d3bf0f6354a1d |
|
MD5 | c371cc3739b136570b0bf9fe161e822b |
|
BLAKE2b-256 | 49bc6ff2e835e0b9562a156c56e325ac3df4c5cf9d3572f212fd25a166be4636 |
File details
Details for the file swarm_bus-4.0-py3-none-any.whl
.
File metadata
- Download URL: swarm_bus-4.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e1bb9be07bac83934dd288a7821e6ba64d003ef8d1944ac0ec320880ce2c74a |
|
MD5 | da9c029d6e387671ce3b885178fcd339 |
|
BLAKE2b-256 | 3a8beedaa51a2058b1e1206bf5c942b424fcacf9d52250bb4b875a42166e5b8a |