交易喜歡的是通過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
}
}
有一個獨立的後臺庫存的過程,更新的SKU被出售或從上述trnsactions購買的清單創建銷售和採購。
public class InventoryProcessor {
@Scheduled(fixedRate = 900000,initialDelay = 3000) // 15 mins
@Transactional
public void doInventory() {
// open Transactions, update inventory records
}
}
此過程每15分鐘運行一次。但是,每當新的交易到達時,都需要明確地觸發或通知InventoryProcessor
doInventory
方法立即執行庫存。
春天有沒有選擇。
你能否解釋有點 – vels4j
編輯,包括代碼 – Gee2113
不能,請求的執行發佈自定義事件不能等到庫存處理器完成。庫存處理器是一個耗時的過程 – vels4j