我需要实现以下行为:
429 Too many requests,则最多重试 3 次,延迟 1 秒我想使用 Spring WebClient 来实现此目的,并提出了以下代码:
Mono<ClientResponse> response = webClient.post()
.uri(URI.create("/myuri"))
.body(BodyInserters.fromObject(request))
.retrieve()
.onStatus(httpStatus -> httpStatus.equals(HttpStatus.TOO_MANY_REQUESTS),
response -> Mono.error(new TooManyRequestsException("System is overloaded")))
.bodyToMono(ClientResponse.class)
.retryWhen(Retry.anyOf(TooManyRequestsException.class)
.fixedBackoff(Duration.ofSeconds(1)).retryMax(3))
.doOnError(throwable -> saveToDB(some_id, throwable))
.subscribe(response -> logResponse(some_id, response));
Run Code Online (Sandbox Code Playgroud)
现在我想测试重试机制和错误处理是否按我的预期工作。也许我可以使用StepVerifier来达到此目的,但我只是不知道如何在我的情况下使用它。有什么有用的提示吗?
reactive-programming rx-java project-reactor spring-webclient
我在当前项目中使用Spring Data和Neo4j并处于以下情况:
@RestController
@RequestMapping(value = SearchResource.URI)
public class PersonResource {
public static final String URI = "/person";
@Autowired
PersonRepository personRepository;
@GetMapping
public Collection<Person> findPersons(
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "birthDate", required = false) Long birthDate,
@RequestParam(value = "town", required = false) Spring town) {
Collection<Person> persons;
if (name != null && birthDate == null && town == null) {
persons = personRepository.findPersonByName(name);
} else if (name != null && birthDate != null && town == …Run Code Online (Sandbox Code Playgroud) 我是d3js和所有javascript世界的新手.在我的html文件中,我只需导入脚本:
<script src="https://d3js.org/d3.v4.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
通过尝试使用以下内容:
var ordinalColorScale = d3.schemeCategory20();
Run Code Online (Sandbox Code Playgroud)
我得到了例外
未捕获的TypeError:d3.schemeCategory20不是index.html上的函数:48
我是否需要任何其他必须导入的d3js模块?或者可能导致问题的原因是什么?
我有以下案例类
case class Station(id: Long, name: String) extends Node
Run Code Online (Sandbox Code Playgroud)
和一个站的 Spark 数据集
vertices: org.apache.spark.sql.Dataset[Station] = [id: bigint, name: string]
Run Code Online (Sandbox Code Playgroud)
我想将顶点数据集转换为 Seq[Station]。我找到了很多关于如何从序列创建数据集的教程,反之亦然。你对我有什么暗示吗?