Skip to main content

amqpstorm library for Flask

Project description

AMQP Service for Flask Apps

Features

  • Connection validation and reconnection for AMQP.
  • Sending messages to a specified exchange with retries.
  • Consuming messages from a queue with retries.
  • Customizable parameters for exchanges and queues.
  • Message headers and properties support.
  • Multi-threading support for consumers.

Prerequisites

  • Python 3.x
  • Flask
  • amqpstorm
  • retry

Installation

To install the required dependencies, run:

pip install amqpstorm-flask

Usage

Initialization

First, create a Flask app and initialize the RabbitMQ.

from flask import Flask
app = Flask(__name__)
app.config["MQ_URL"] = "<Your_MQ_URL>"
app.config["MQ_EXCHANGE"] = "<Your_MQ_Exchange_Name>"

amqp_service = RabbitMQ()
amqp_service.init_app(app)

Sending Messages

To send a message to a specified exchange:

amqp_service.send(
    body={"key": "value"},
    routing_key="route.key",
    exchange_type="direct",
    retries=5,
)

Consuming Messages

To consume messages from a specified queue:

@amqp_service.queue(
    queue_name="test_queue",
    routing_key="route.key",
)
def process_message(message):
    print(message.body)

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

amqpstorm_flask-0.4.7.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

amqpstorm_flask-0.4.7-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file amqpstorm_flask-0.4.7.tar.gz.

File metadata

  • Download URL: amqpstorm_flask-0.4.7.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for amqpstorm_flask-0.4.7.tar.gz
Algorithm Hash digest
SHA256 2a93977a2513b39ff844eba07a01ea705afd1420a2fbc25bdbcc2fd88288e750
MD5 b99be6e055a9d30d6b6c1b01c25aa7af
BLAKE2b-256 2c03099634acb720d71d24fe6fcba087d8a43ca847bd59ef37883fa412753a77

See more details on using hashes here.

File details

Details for the file amqpstorm_flask-0.4.7-py3-none-any.whl.

File metadata

File hashes

Hashes for amqpstorm_flask-0.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6ac22389beb177be38bd576fc60ed38f6415bc7f8c8f40c11a1f5e4e5f812788
MD5 4fc4fae867778863ce1b49e03e3c08e1
BLAKE2b-256 f725788a00e39be5770a26513cd4206285c11856d0d959627c71394a19be63e4

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