Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

amqpstorm-flask

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amqpstorm-flask

amqpstorm library for Flask

  • 0.4.7
  • PyPI
  • Socket score

Maintainers
1

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)

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc