A simple NestJS server integrated with RabbitMQ, designed to save entities to MongoDB.
This repo sends a user_created
event to RabbitMQ after saving a user in MongoDB.
This project works seamlessly with another service that receives the user_created
events and sends notifications. Check out that repo here: Telegram Notify
Create a .env
file in the root directory
In the root of your project directory, create a .env file with the following content:
MONGODB_URL=your mongo uri
RABBITMQ_URL=your rabbit uri
RABBITMQ_USERS_QUEUE=users_queue
If you want to run Docker Compose and use your local MongoDB, you'll need to modify the MongoDB configuration to allow external connections.
-
Open the MongoDB configuration file
mongod.conf
. -
Edit the following line to enable connections from any IP address:
net:
# Other configurations...
# Enable connection from any IP address
bindIp: 0.0.0.0
- Restart MongoDB
If you want to run Docker Compose and use your local RabbitMQ instance, you'll need to modify the RabbitMQ configuration to specify the IP address.
-
Open the RabbitMQ configuration file
rabbitmq.conf
. If it doesn't exist, create it in the RabbitMQ directory/etc/rabbitmq/
. -
Add the following line to specify the IP address:
listeners.tcp.default = [your ip address]:5672
- Restart RabbitMQ