Skip to content

seymasa/rabbitMQ-producer-consumer-fastAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConsumerExample-service

This project was created with Python and FastAPI framework.

Environment

Please set up your Python version to 3.10

  • python3 --version

Create your .env file.

  • cd <project-directory>
    $ touch .env
APP_NAME=Example
APP_VERSION=1.0.1
ENV=local
APP_PORT=3002
APP_HOST=localhost
BODY_LIMIT=12000
LOG_LEVEL=info
SWAGGER_ENABLED=true
DEBUG=true
MICROSERVICE_CLIENT_TIMEOUT=60
RABBITMQ_HOST=localhost
RABBITMQ_PORT=5672
RABBITMQ_USERNAME=guest
RABBITMQ_PASSWORD=guest
RABBITMQ_EXCHANGE_NAME=message_exchange
RABBITMQ_EXCHANGE_TYPE=fanout
RABBITMQ_QUEUE=message_queue
RABBITMQ_ROUTING_KEY=0
RABBITMQ_CONNECTION_ATTEMPTS=0
RABBITMQ_RETRY_DELAY=0

Setting Development Environment

  • Install virtual environment
    $ pip install virtualenv
  • Created virtual environment
    $ virtualenv env
  • Activate the virtual environment
    $ source env/bin/activate
  • Install libraries
    $ pip install -r requirements.txt

Run Service

    $ python3 main.py

Swagger Documents

Producer Exec

  • Setup RabbitMQ
    $ brew update
    $ brew install rabbitmq
    $ brew info rabbitmq
  • Configration RabbitMQ

CONF_ENV_FILE="/opt/homebrew/etc/rabbitmq/rabbitmq-env.conf" /opt/homebrew/opt/rabbitmq/sbin/rabbitmq-server

  • RabbitMQ service start & stop
    $ brew services start rabbitmq

&&

    $ brew services stop rabbitmq

Run Producer

Don't forget to enable virtual environment

    $ cd producer
    $ python3 app.py

Releases

No releases published

Packages

No packages published

Languages