0

Transaction Workflow:

  1. Validate Funds – Verify the sender’s account has sufficient balance.
  2. Withdraw Funds – Deduct the specified amount from the sender’s account.
  3. Transfer Funds – Credit the recipient’s account.
  4. Notify Parties – Send transaction receipts to both sender and recipient. If any step between 1 and 3 fails and retries are unsuccessful, the system must initiate a rollback to restore the previous state (e.g., refund the sender if the transfer fails).

Microservices Overview:

  • Service A – Retrieves bank account details.
  • Service B – Handles fund withdrawal.
  • Service C – Manages fund transfer to the recipient.
  • Service D – Sends transaction notifications.

Proposed AMQP-Based Architecture:

  • A producer sends a message to the queue with a unique identifier (GUID).
  • Service A consumes the message, validates the sender’s account, and publishes a new message if funds are sufficient.
  • Service B picks up the message, withdraws funds, and publishes a follow-up message.
  • Service C consumes the message, attempts the transfer, and publishes a rollback message if the transfer fails after retries.
  • Service B listens for rollback messages and reverses the withdrawal if necessary.

Architectural Concern:

The current design introduces redundancy and complexity by chaining service operations through sequential message passing. Ideally, these operations should be encapsulated within a single transactional context to ensure atomicity and simplify rollback logic.

How can I employ AMQP/RabbitMq to satisfy these architectural concerns?

3
  • 3
    Make a single service. Commented Oct 23 at 20:46
  • You need to provide more detail on what the real issue is. eg. say i do all this manually via paper messages sent via carrier Pidgeon. As long as the accounts in question are locked until the end. I can undo it all. it doesn't matter how long it takes or anything. If I control all the accounts, or allow negative balances I can roll back old transactions from years ago without locking Commented Oct 23 at 22:04
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Commented Oct 25 at 15:25

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.