eandersson / amqpstorm-pool

AMQPStorm connection pooling based on pika-pooling.

Repository from Github https://github.comeandersson/amqpstorm-poolRepository from Github https://github.comeandersson/amqpstorm-pool

AMQPStorm-Pool

AMQPStorm connection pooling based on pika-pool.

Version Travis Coverage

usage

Get it:

pip install amqpstorm-pool

and use it:

import json

import amqpstorm
import amqpstorm_pool

uri = 'amqp://guest:guest@localhost:5672/%2F?heartbeat=60'
pool = amqpstorm_pool.QueuedPool(
    create=lambda: amqpstorm.UriConnection(uri),
    max_size=10,
    max_overflow=10,
    timeout=10,
    recycle=3600,
    stale=45,
)

with pool.acquire() as cxn:
    cxn.channel.queue.declare('fruits')
    cxn.channel.basic.publish(
        body=json.dumps({
            'type': 'banana',
            'description': 'they are yellow'
        }),
        exchange='',
        routing_key='fruits',
        properties={
            'content_type': 'text/plain',
            'headers': {'key': 'value'}
        }
    )

About

AMQPStorm connection pooling based on pika-pooling.

License:Other


Languages

Language:Python 100.0%