Azure active directory MSAL4j-如何处理MsalThrottlingException?

Azure active directory MSAL4j-如何处理MsalThrottlingException?,azure-active-directory,msal,microsoft-identity-platform,microsoft-identity-web,Azure Active Directory,Msal,Microsoft Identity Platform,Microsoft Identity Web,我使用MSAL4j,并且有一个名为MsalThrottlingException的异常类型。当我抓到它时,我该如何处理它?我需要一个示例实现 try{ Future<IAuthenticationResult> future = confidentialClientApplication.acquireToken(authorizationCodeParameters); IAuthenticationResult authenticationResult

我使用MSAL4j,并且有一个名为MsalThrottlingException的异常类型。当我抓到它时,我该如何处理它?我需要一个示例实现

try{
    Future<IAuthenticationResult> future = 
    confidentialClientApplication.acquireToken(authorizationCodeParameters);
    IAuthenticationResult authenticationResult = future.get(1, TimeUnit.MINUTES); 
}
catch(ExecutionException e){
    if(e.getCause() instanceof MsalThrottlingException){
        //how to handle it
    }
}
试试看{
未来=
机密ClientApplication.acquireToken(authorizationCodeParameters);
IAAuthenticationResult authenticationResult=future.get(1,TimeUnit.MINUTES);
}
捕获(执行例外){
if(例如,MsalThrottlingException的getCause()实例){
//如何处理
}
}

也有关于它的文档(您可以在上面的链接中看到屏幕截图),但它没有给出处理实现的示例。你能举个例子吗?

这对我很有效:

    private static String PREFIX_RETRY_STR = "com.microsoft.aad.msal4j.MsalThrottlingException: Request was throttled according to instructions from STS. Retry in ";
    private static String SUFFIX_RETRY_STR = " ms.";

(...)

            if (e.getCause() instanceof MsalThrottlingException) {
                int waitTime = Integer.parseInt(e.getMessage().replace(PREFIX_RETRY_STR, "").replace(SUFFIX_RETRY_STR, ""));
                try {
                    TimeUnit.MILLISECONDS.sleep(waitTime);
                } catch (InterruptedException interruptedException) {
                    interruptedException.printStackTrace();
                }
                result = pca.acquireToken(parameters).join();
            } else
                throw e;

请尝试执行以下步骤: