Skip to main content

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)

# We purge a known queue

# Now we add a new queue on the fly
bus.register_queue('new_queue', {'wait': 20})


Using as a producer

with AMQP(uri, transport, queues) as producer:
        {'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):

def error_handler(body, message):
    raise ValueError('Error while processing message')

with AMQP(uri, transport, queues) as consumer:
        [print_routing_key, ack_message],

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
swarm_bus-3.3-py2-none-any.whl (8.0 kB) Copy SHA256 hash SHA256 Wheel py2
swarm-bus-3.3.tar.gz (5.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page