This Rest service works in parallel of worker service called WorkerServiceBasedRabbitMQ. The Rest service send data to the worker service through RabbitMQ, then it is saved in a local SqlServer Database.
It's recommanded to launch first the WorkerServiceBasedRabbitMQ. For details, please go to WorkerServiceBasedRabbitMQ repository and open the Readme file.
- [ASP.NET Core 6]
- [Entity Framework Core 7]
- [RabbitMQ]
- [Docker]
- [LocalDB Sql Server]
- Given that Docker is installed, we’ll open a command-line terminal and use the docker run command to spin up our server: docker run -d --hostname my-rabbitmq-server --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
- Run command : docker start rabbitmq
- Navigate to http://localhost:15672
- Login as guest (Username : guest, Password : guest)
- Download the ServiceBasedRabbit application
- Open Windows command prompt and go to : ServiceBasedRabbit.api folder
- Launch dotnet run
- Navigate to : http://localhost:5195/swagger/index.html
- Download the WorkerServiceBasedRabbitMQ application
- Open Windows command prompt and go to : WorkerServiceBasedRabbitMQ folder
- Launch dotnet run
WorkerServiceBasedRabbitMQ application is configured to use a (localDB) Sql Server database. This ensures that all users will be able to run the solution without needing to set up additional infrastructure (e.g. SQL Server).
Set up a local Sql Server Database:
- Open Windows command prompt
- Launch sqllocaldb create "local"
- Open MSSQL Management Studio
- Connect to server : (localdb)\local
This step is about to create the RabbitMQ Database in the LocalDB, before starting to use the applications:
2 ways for creating:
- From Visual Studio
- Open Package Manager Console
- Run PM> add-migration Migration-1
- Run PM> Update-Database
- Check RabbitMQ Database that is created
- From .Net CLI
- Run dotnet ef migrations add Migration-1
- Run dotnet ef database update
- Check RabbitMQ Database that is created
- Go to Rest Service ServiceBasedRabbit
- Post a new User
- Check WorkerServiceBasedRabbitMQ windows : you have to get the message (the user you just post).
- Check the database, User table to see it has been created.
N.B. I Apologize but for this moment, only Posting a new User is working.
This project is designed using Clean Architecture.