Skip to main content

ESB SQS based

Project description

Client side implementation of an ESB with Amazon SQS.

Simple Usage

# Default transport config
transport = {
    'prefix': 'dev-%(hostname)s-',
    'priorities': ['low', 'medium', 'high'],
    'polling_interval': 20,                   # Default queue polling interval
    'retention_period': 864000,               # Default queue retention period
    'visibility_timeout': 30,                 # Default queue visibility timeout
    'sleep_time': 0,                          # Default queue sleep time
    'office_hours': True,
    'region': 'eu-west-1'
}

bus = SwarmBus('LOGIN', 'PASSWORD', **transport)
bus.connect()

queue_config = {
    'visibility_timeout': 5
}

# Now we register a new queue
bus.register_queue('new_queue', **queue_config)

# Disconnect the bus to finish
bus.disconnect()

Using as a producer

with SwarmBus('LOGIN', 'PASSWORD', **transport) as producer:
    producer.register_queue('new_queue')

    producer.publish(
        'new_queue',
        {'id': 42}
    )

    producer.publish(
        'new_queue',
        {'id': 84},
        priority=1,  # Priority index, correspond to 'medium'
        delay=5      # Delay of the message
    )

Using as a consumer

def handle_message(body, message):
    print(body)
    message.delete()

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

with SwarmBus('LOGIN', 'PASSWORD', **transport) as consumer:
    consumer.register_queue('new_queue')

    consumer.consume(
        'new_queue',
        handle_message,
        error_handler
    )

Project details


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-5.4.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

swarm_bus-5.4-py2-none-any.whl (11.6 kB view details)

Uploaded Python 2

File details

Details for the file swarm-bus-5.4.tar.gz.

File metadata

  • Download URL: swarm-bus-5.4.tar.gz
  • Upload date:
  • Size: 6.1 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

Hashes for swarm-bus-5.4.tar.gz
Algorithm Hash digest
SHA256 0c5c7a98fc095bfff70dfa80fb2ba38a9aac2364a409809c2554d689fbb39292
MD5 093c3326f49bc5d624884f269f65f0f1
BLAKE2b-256 29764a0a560007e2acc3c7b3d1c36e3932da67a99dc1ce15ec68532cd7f0658d

See more details on using hashes here.

File details

Details for the file swarm_bus-5.4-py2-none-any.whl.

File metadata

  • Download URL: swarm_bus-5.4-py2-none-any.whl
  • Upload date:
  • Size: 11.6 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

Hashes for swarm_bus-5.4-py2-none-any.whl
Algorithm Hash digest
SHA256 00461e235a0dfb646b1be191b7e2aa880d0d4ff37a8d9d1683d009a2b42a9030
MD5 c90a36a061363f43c59c35a640d31366
BLAKE2b-256 92d852f3308be19e157cc8e62fea815f299d487607b2e671640f3f514df098d7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page