Skip to content

Commit

Permalink
fin d'intégration de rabbitmq
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent228 committed Sep 15, 2024
1 parent 24912ae commit 9437702
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
52 changes: 26 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@ FROM python:3.11-slim-buster

WORKDIR /app

# set environment variables
ARG SECRET_KEY
ARG DEBUG
ARG ALLOWED_HOSTS_1
ARG ALLOWED_HOSTS_2
ARG CUSTOMER_API_URL
ARG DB_HOST
ARG MYSQL_PORT
ARG MYSQL_ROOT_PASSWORD
ARG MYSQL_DATABASE
ARG MYSQL_USER
ARG MYSQL_PASSWORD
ARG MYSQL_TEST_DATABASE

ENV SECRET_KEY=${SECRET_KEY}
ENV DEBUG=${DEBUG}
ENV ALLOWED_HOSTS_1=${ALLOWED_HOSTS_1}
ENV ALLOWED_HOSTS_2=${ALLOWED_HOSTS_2}
ENV CUSTOMER_API_URL=${CUSTOMER_API_URL}
ENV DB_HOST=${DB_HOST}
ENV MYSQL_PORT=${MYSQL_PORT}
ENV MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
ENV MYSQL_DATABASE=${MYSQL_DATABASE}
ENV MYSQL_USER=${MYSQL_USER}
ENV MYSQL_PASSWORD=${MYSQL_PASSWORD}
ENV MYSQL_TEST_DATABASE=${MYSQL_TEST_DATABASE}
# # set environment variables
# ARG SECRET_KEY
# ARG DEBUG
# ARG ALLOWED_HOSTS_1
# ARG ALLOWED_HOSTS_2
# ARG CUSTOMER_API_URL
# ARG DB_HOST
# ARG MYSQL_PORT
# ARG MYSQL_ROOT_PASSWORD
# ARG MYSQL_DATABASE
# ARG MYSQL_USER
# ARG MYSQL_PASSWORD
# ARG MYSQL_TEST_DATABASE

# ENV SECRET_KEY=${SECRET_KEY}
# ENV DEBUG=${DEBUG}
# ENV ALLOWED_HOSTS_1=${ALLOWED_HOSTS_1}
# ENV ALLOWED_HOSTS_2=${ALLOWED_HOSTS_2}
# ENV CUSTOMER_API_URL=${CUSTOMER_API_URL}
# ENV DB_HOST=${DB_HOST}
# ENV MYSQL_PORT=${MYSQL_PORT}
# ENV MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
# ENV MYSQL_DATABASE=${MYSQL_DATABASE}
# ENV MYSQL_USER=${MYSQL_USER}
# ENV MYSQL_PASSWORD=${MYSQL_PASSWORD}
# ENV MYSQL_TEST_DATABASE=${MYSQL_TEST_DATABASE}

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
Expand Down
Binary file modified kawa_product/__pycache__/settings.cpython-311.pyc
Binary file not shown.
Binary file modified services/__pycache__/rabbitmq_service.cpython-311.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions services/rabbitmq_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Publier un message dans une queue RabbitMQ
def publish_to_queue(queue_name, message):
try:
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
connection = pika.BlockingConnection(pika.ConnectionParameters('host.docker.internal'))
logger.debug("Connexion à RabbitMQ établie pour la publication")
channel = connection.channel()

Expand All @@ -29,7 +29,7 @@ def publish_to_queue(queue_name, message):
# Consommer des messages depuis une queue RabbitMQ
def consume_from_queue(queue_name, callback):
try:
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
connection = pika.BlockingConnection(pika.ConnectionParameters('host.docker.internal'))
logger.info("Connexion à RabbitMQ établie pour la consommation")
channel = connection.channel()

Expand Down

0 comments on commit 9437702

Please sign in to comment.