...
/Creating a RabbitMQ Consumer for the Houses App
Creating a RabbitMQ Consumer for the Houses App
Learn how to create a RabbitMQ consumer in Django.
We'll cover the following...
We'll cover the following...
Creating a consumer for the Config and Houses apps
In RabbitMQ, the word consumer refers to any application or program that receives messages. Therefore, consuming means receiving.
To create a RabbitMQ consumer for the Config and Houses app, we'll create a file in the backendservice1 app directory named consumer.py. Then, we open the file and import os, django, pika, and json, as follows:
import os, django, pika, json
We also have to set up our OS environment and Django:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
django.setup()
We then import our House model from the models.py file in the houses app, but only after calling the django.setup():
from houses.models import ...