Click here to Skip to main content
15,437,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a project which we got from vendor and the project right now is just imperative with so much tight coupling and no clean code practices.

Now we are thinking to reengineer complete application and thinking to have DDD approach with event driven architecture.

I want to know how do we handle situation where one transaction depends upon the other

For example

We have one billing service and other inventory

During billing retailer first selects or add a new customer and then finds a product and if not found create one for his inventory and then that product is available for billing to customers .

So here we have four services customer, billing and inventory, notification

As of now we have backend logic sth like this
import {addCustomer, findCustomer } from './addCustomer'; 
import {addProductToInventory, findProductInInventory} from './addProductToInventory'; 
import {notification } from './notificationService'; 
import {createBill, generateInvoice } from './billingService';  
const makeBill = async (req, res) => 
  let {customer, inventoryProducts, billData} = req.body;    
   const customerId = await findCustomer(customer);   
       customerId = await addCustomer(customer)   
  inventoryProducts.forEach( product => {     
        const productId = await findProductInInventory(product);     
             productId = await addProductToInventory(product);

 let billId = await createBill(customerId, productId, billData);  
  await generateInvoice(billId, billData);  
  notification(billId, billData, userData);     

What I have tried:

If we use some event store and store all the transactions states, How can we handle event if each process depends upon another unless we know the transaction happened ?

Note: This is just example of process right now, its is not the implementation of domains, just wanted to know how event driven will work in such situations
Updated 25-Jan-22 0:05am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900