Spring与缓存和http.outboundGateway集成

时间:2018-04-13 09:30:57

标签: spring spring-boot spring-integration-dsl

我正在尝试实现缓存以避免多次调用Rest API。以下是API call的实施代码。我不是每次都调用API,而是将API结果放在hashmap中,使用payload对象作为键,结果作为值。我尝试了不同的方法,但我无法找到解决方案。拜托,请帮帮我。

@Bean
public IntegrationFlow read() {
    return IntegrationFlows.from("input").split(new PayLoadSplitter()).enrichHeaders(p -> p.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML))
            .handle(Http.outboundGateway("http://localhost:8080/service/publications/{name}")
                    .httpMethod(HttpMethod.GET).expectedResponseType(String.class).uriVariable("name", p->p.getPayload())).aggregate().get(); 
}

0 个答案:

没有答案