in src/main/java/com/aliyun/mns/client/CloudQueue.java [621:642]
public List<Message> batchPopMessage(int batchSize, int waitSeconds)
throws ServiceException, ClientException, ServiceHandlingRequiredException {
BatchReceiveMessageAction action = new BatchReceiveMessageAction(serviceClient,
credentials, endpoint);
BatchReceiveMessageRequest request = new BatchReceiveMessageRequest();
request.setBatchSize(batchSize);
request.setWaitSeconds(waitSeconds);
request.setRequestPath(queueURL);
try {
return action.executeWithCustomHeaders(request, customHeaders);
} catch (ServiceException e) {
if (isMessageNotExist(e)){
// 没拉到消息,合理
return null;
}
if (isServiceHandlingRequired(e)){
// 远程服务不可用,需要上游感知并强制捕获异常处理
throw new ServiceHandlingRequiredException(e.getMessage(),e,e.getErrorCode(),e.getRequestId(),e.getHostId());
}
throw e;
}
}