Transactions likes sales and purchase that are created via REST
@Component
@Path("txns")
public class Transaction {
@Path("/purchases")
public Response postPurchaseTrnsaction(Transaction txn) {
// persistence takes place here
}
@Path("/sales")
public Response postSalesTrnsaction(Transaction txn) {
// persistence takes place here
}
}
There is a separate Background Inventory process that updates Inventory of SKUs which are sold or purchased from the above trnsactions.
public class InventoryProcessor {
@Scheduled(fixedRate = 900000,initialDelay = 3000) // 15 mins
@Transactional
public void doInventory() {
// open Transactions, update inventory records
}
}
This process runs every 15 mins. However, whenever a new transactions arrive, need to trigger or notify the InventoryProcessor
doInventory
method explicitly to perform inventory immediately.
Is there a option in spring.