Skip to content

A microservice architecture template implementing CQRS and Mediator patterns for purchase transactions.

Notifications You must be signed in to change notification settings

dev-fatih-erol/Buying

Repository files navigation

Overview

This microservice is designed to manage and process users' gold purchase requests regularly. Users can select a specific day and set it as the designated day of each month. The microservice, upon reaching this date, processes the gold purchase requests of users for the specified amount, and executes the relevant transactions.

Technologies and Architectures

  • Docker: An open-source platform used for running applications in virtual environments.
  • .NET Core: Lightweight, fast, and cross-platform framework.
  • PostgreSQL: An open-source and powerful relational database management system.
  • RabbitMQ: Middleware used for message queues and event-based communication.
  • CQRS: An architectural approach that separates command and query responsibilities.

Usage

This is the view of the microservice from above 1

The 5 main tasks of microservice are:

  • Create instruction
       post /instructions
  • Cancel instruction
       put /instructions/cancel
  • Get active instruction
       get /instructions/active
  • Filter and list canceled instructions
       get /instructions/cancelled
  • List notification channels for an instruction
       get /instructions/instructioId/channels

The instruction process includes the following elements:

When creating instructions, the user selects the amount to be received, the instruction day, and the notification channels. At the same time, when the instruction is added to the database, the delivery date of the message is calculated and sent to RabbitMQ as a Delayed Message. When the message is consumed from RabbitMQ, the purchase transaction occurs, and notifications are sent to the channels selected by the user. Subsequently, the next delivery date is calculated and requeued. This cycle continues until the user cancels the instruction. In RabbitMQ, in case of message processing failure, the Retry Policy comes into play to ensure that messages are resent. Additionally, when a user cancels an instruction, the message is removed from the queue and the current status is recorded in the database.

Please refer to the image for a more detailed examination. 2

Deploy and Scale

  • Load Balancing and Queue Scaling
  • Adjusting Queue and Consumer Counts



Thank you for reading.

About

A microservice architecture template implementing CQRS and Mediator patterns for purchase transactions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published