循环中的Java异步rest调用

循环中的Java异步rest调用,java,rest,asynchronous,spring-boot,Java,Rest,Asynchronous,Spring Boot,我有一个rest服务返回客户的名称,我想进行一个异步调用来检索客户列表的名称 因此,我有一个客户列表,目前我正在迭代该列表并逐一拨打电话: public List<Participant> retrieveParticipantsFullName(List<Participant> participantList) throws GeneralException { for (Participant participant : participantList)

我有一个rest服务返回客户的名称,我想进行一个异步调用来检索客户列表的名称

因此,我有一个客户列表,目前我正在迭代该列表并逐一拨打电话:

 public List<Participant> retrieveParticipantsFullName(List<Participant> participantList) throws GeneralException {

    for (Participant participant : participantList) {
        String fullRetrievePartFullURL = retrieveParticipantsFullNameUrl+participant.getCustomerType()+"/"+participant.getCustomerID();
        ResponseEntity<RetrieveCustomerNameResponse> resultResp ;

            resultResp =  restTemplate.getForEntity(fullRetrievePartFullURL,
                    RetrieveCustomerNameResponse.class);
            participant.setCustomerMiddlename(resultResp.getBody().getCustomerNameOut().getCustomerMiddlename());
    }

    return participantList;
有没有办法以异步方式进行此调用,以便并行执行

谢谢 关于

是,您需要使用AsyncRestTemplate,而不是使用RestTemplate,它返回ListenableFutures