Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure active directory 如何使用MS JAVA SDK for GRAPH API重试请求?_Azure Active Directory_Microsoft Graph Api_Microsoft Graph Sdks - Fatal编程技术网

Azure active directory 如何使用MS JAVA SDK for GRAPH API重试请求?

Azure active directory 如何使用MS JAVA SDK for GRAPH API重试请求?,azure-active-directory,microsoft-graph-api,microsoft-graph-sdks,Azure Active Directory,Microsoft Graph Api,Microsoft Graph Sdks,我是一个使用Graph API的初学者,目前正在尝试处理代码中与节流相关的错误。在sdk的github页面中有一个RetryHandler类。但我似乎找不到示例请求的代码实现。有没有我可以检查和尝试的例子 作为一个例子,我可以在下面给出我自己的代码 @Override public JsonObject getUserList(String accessToken){ LOGGER.trace("Querying directRoutingEnabled users"

我是一个使用Graph API的初学者,目前正在尝试处理代码中与节流相关的错误。在sdk的github页面中有一个RetryHandler类。但我似乎找不到示例请求的代码实现。有没有我可以检查和尝试的例子

作为一个例子,我可以在下面给出我自己的代码

@Override
public JsonObject getUserList(String accessToken){
    LOGGER.trace("Querying directRoutingEnabled users");
    final String selectQuery = "mail,givenName,surname,displayName";
    final List<Option> requestOptions = new LinkedList<>();
    final String filterQuery = createFilterQuery();

    requestOptions.add(new HeaderOption(CONSISTENCY_LEVEL, EVENTUAL));
    requestOptions.add(new QueryOption(SELECT, selectQuery));
    requestOptions.add(new QueryOption(COUNT, true));
    requestOptions.add(new QueryOption(FILTER, filterQuery));

    IGraphServiceClient graphServiceClient = GraphServiceClient.builder().authenticationProvider(new SimpleAuthProvider(accessToken)).buildClient();
    IUserCollectionRequest request = graphServiceClient
            .users()
            .buildRequest(requestOptions);
    IUserCollectionPage users = request.get();
    return users.getRawObject();
}

如何使用retry after机制以及使用Graph SDK for Java进行错误处理来覆盖这段代码?

核心库中的默认中间件附带了默认的RetryHandler实现。多亏了a,它还可以处理节流错误

从SDK的V3开始,可以使用自定义拦截器指定自定义OkHttpClient。可在此处找到自定义准则:

默认RetryHandler实现:


默认RetryHandler设计:

除了所有这些好信息之外,java SDK还为select、orderby、count、EXPLAND。。。请参阅文档。它应该允许您编写更少的代码。谢谢你的回答。但我也想知道如何使用这个处理程序。例如,我应该使用try-catch块并在catch处处理节流吗?除了默认的RetryHandler实现之外,是否还有其他示例可供我查看和尝试?我相信我理解这个概念,但是实际的实现对我来说仍然是混乱的。