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'], 'queue_living': 864000, # Default living message 'queue_sleeping': 0, # Default sleep time between messages 'queue_visibility': 30 # Default visibility message 'queue_waiting': 10 # Default long polling seconds } queues = { 'my_queue': { 'route': 'my.queue.route', # Specific route 'sleep': 60, # Seconds before next call to SQS 'visibility': 1800, # Visibility message in queue 'wait': 20 # 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.1.tar.gz
(6.7 kB
view details)
Built Distribution
File details
Details for the file swarm-bus-4.1.tar.gz
.
File metadata
- Download URL: swarm-bus-4.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/36.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a5fd797af6367c0045819eec1ecff539360a999026c466a0a59bb96cc2b965f |
|
MD5 | 667ada08846ea900b7a5406f1c8f98f2 |
|
BLAKE2b-256 | 7d1dbf4bc9f43497bc2faa3e17646fb6ff67e313de8778a3cd37c9caf07e813f |
File details
Details for the file swarm_bus-4.1-py2-none-any.whl
.
File metadata
- Download URL: swarm_bus-4.1-py2-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/36.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f78c2762bec2df0f07f1a1f2b028d947913657426ee6d6319e5cb27c3acdfd25 |
|
MD5 | a50a7217f3033cc11580ed5969d1e3a1 |
|
BLAKE2b-256 | f5756d22ac19b8f6fef328a49a4b240e08588f6a2f795f286e92091dd9555356 |