上QQ阅读APP看书,第一时间看更新
The @Bulkhead policy
The @Bulkhead annotation can also be applied to a class or method to enforce the bulkhead policy. This pattern isolates failures in the current operation to preserve the execution of other operations. The implementation does this by limiting the number of concurrent invocations on a given method:
@Bulkhead(4)
public void bulkheadedOperation() {
...
}
In the previous code, this method only supports four invocations at the same time. Should more than four simultaneous requests come into the bulkheadedOperation method, the system will hold the fifth and later requests until one of the four active invocations completes. The bulkhead annotation can also be used with @Asynchronous to limit the thread number in an asynchronous operation.