Skip to main content

Adds Rabbitmq support to your Flask application.

Project description


Flask-Rabmq is an extension for Flask that adds support for Rabbitmq to your application. It aims to simplify using Rabbitmq with Flask by providing useful defaults and extra helpers that make it easier to accomplish common tasks.


Install and update using pip:

$ pip install -U Flask-Rabmq

A Simple Example

import logging

from flask import Flask

from flask_rabmq import RabbitMQ

logging.basicConfig(format='%(asctime)s %(process)d,%(threadName)s %(filename)s:%(lineno)d [%(levelname)s] %(message)s',
                    datefmt='%Y-%m-%d %H:%M:%S',

logger = logging.getLogger(__name__)

app = Flask(__name__)

app.config.setdefault('RABMQ_RABBITMQ_URL', 'amqp://username:password@ip:port/dev_vhost')
app.config.setdefault('RABMQ_SEND_EXCHANGE_NAME', 'flask_rabmq')
app.config.setdefault('RABMQ_SEND_EXCHANGE_TYPE', 'topic')
app.config.setdefault('RABMQ_SEND_POOL_SIZE', 2)
app.config.setdefault('RABMQ_SEND_POOL_ACQUIRE_TIMEOUT', 5)

ramq = RabbitMQ()

def hello_world():
    # send message
    ramq.send({'message_id': 222222, 'a': 7}, routing_key='flask_rabmq.test', exchange_name='flask_rabmq')
    # delay send message, expiration second(support float).
    ramq.delay_send({'message_id': 333333, 'a': 7}, routing_key='flask_rabmq.test', exchange_name='flask_rabmq',
    return 'Hello World!'

@ramq.queue(exchange_name='flask_rabmq', routing_key='flask_rabmq.test')
def flask_rabmq_test(body):
    return True

if __name__ == '__main__':

Project details

Download files

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

Files for flask-rabmq, version 0.0.19
Filename, size File type Python version Upload date Hashes
Filename, size flask_rabmq-0.0.19.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page