簡體   English   中英

在Spring Boot中,我有一個異步調用,我必須等待下一個線程等待直到CRUD操作

[英]In Spring Boot i have a Async call and I have to wait my next thread to wait till CRUD Operation

在我的項目中..我有一個方法createUserRespone() ,用於將響應發送給用戶,在進行異步調用之前,它會執行一些數據庫操作,並且在createUserRespone()方法中,我正在從數據庫中獲取值,並在獲取時我要檢查值是否在數據庫中轉儲的數據

例:

// here importScore is AN Async method
irResponse = scoreManager.importScore(fileUpload, loggedInUser);

CreateUserResponse response= this.createUserRespone( a, b);


private CreateUserResponse  createUserRespone(String a, Object b){

    // here I am fetching those values which are inserted from Async method call

}

我的問題

  1. 我如何驗證值是通過createUserRespone()方法中的Async方法調用插入數據庫中的。

  2. 我們如何使用Executor框架或任何其他替代方案來實現它,我們也會感激不盡?

請不要說使其成為同步通話

您需要等待的句柄。 第一個方法必須返回Future ,或者必須返回用於執行任務的Thread (通過使用Future.getThread.join等待)。

如果第一個方法不能返回任何句柄,則必須在數據庫中進行一些輪詢,然后循環等待直到發生預期的數據更改。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM