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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amqpstorm_flask-0.5.3-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: amqpstorm_flask-0.5.3.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for amqpstorm_flask-0.5.3.tar.gz
Algorithm Hash digest
SHA256 3de186b91e34c93e4cd24012eb91e09e19bb9c636718f6a6ac6d40e6b8e471b8
MD5 67ea1af2dfa551899bbd69ad3db90575
BLAKE2b-256 beb2cf4aa7e232009c612e8d911b7117d29f33792d3ee370fb530249ba0f1ced

See more details on using hashes here.

Provenance

The following attestation bundles were made for amqpstorm_flask-0.5.3.tar.gz:

Publisher: python-publish.yml on inuits/amqpstorm-flask

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for amqpstorm_flask-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8c4fdea49d6dbc1dca549fca901290d1168c558cefb81b0d141323af7c396709
MD5 99beed8ce6fe9ad1e962227aa9a23269
BLAKE2b-256 8f85d11b4c8d360cf6c07657654c4ed94ec9f2929acfbf6e25c1321ed5e15121

See more details on using hashes here.

Provenance

The following attestation bundles were made for amqpstorm_flask-0.5.3-py3-none-any.whl:

Publisher: python-publish.yml on inuits/amqpstorm-flask

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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