Future模式
概念
Future模式是多線程設計常用的一種設計模式,類似商品訂單。商品下單后,會立即得
到下單 成 功的通知,客戶不用等待后續商家的操作,只等配送到家即可,下單后到收到商品這
段時間,客戶可以做其他事情,不用在家等著商品。Future模式也類似Ajax的異步請求,
不用等待處理結果
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RpcService {
/**
* The value may indicate a suggestion for a logical component name,
* to be turned into a Spring bean in case of an autodetected component.
* @return the suggested component name, if any
*/
String value() default "";
}
image
客戶端發出call請求,這個請求需要很長一段時間才能返回。客戶端一直等待著,直到數據返回,隨后進行其他業務處理。