关于使用Spring Boot WebFlux Starter

时间:2018-04-17 19:44:02

标签: java spring spring-boot spring-cloud spring-webflux

我创建了2个带有Spring Boot的微服务(版本1.5.1 RELEASE),Spring Cloud(Edgware.SR3),Spring Cloud Starter Config(版本1.4.3 RELEASE)和Netflix的Eureka命名服务器(Spring Cloud Starter Netflix Eureka Client) / Server 1.4.4 RELEASE):

  1. Eureka Server(用于注册微服务的服务)
  2. Eureka客户端(用于保存/更新操作的数据库服务)
  3. Eureka客户端是一个简单的Restful Service,只有一个@PostMapping带注释的方法,它接受相当大的对象作为参数(@RequestBody MyObject object)。

    Eureka客户端成功注册了Eureka服务器。

    然后在 Spring Boot Webflux 的帮助下,我尝试在Spring 5中引入的类WebClient的帮助下访问我的Eureka客户端,并且是{{1}的即兴创作} .class。我做了类似下面的事情:

    AsyncRestTemplate

    在调试时,我发现在上面代码的最后一行之后我得到了OOM异常。

    WebClient webClient = WebClient.create();
    reactor.core.publisher.Mono result = (Mono) webClient.post()
    .uri("http://localhost:8080/eureka-client")
    .body(BodyInserters.fromObject(//myComplexObject here))
    .retrieve()
    .bodyToMono(String.class);
    
    result.subscribe();
    

    下面的完整堆栈跟踪:

    io.netty.handler.codec.EncoderException: java.lang.OutOfMemoryError
    

    我的classpath中有jackson库,依赖spring来序列化我的复杂对象,同时将它传递给Restful服务。我不确定是什么原因引起的。有什么指针吗?

0 个答案:

没有答案