在Http出站网关上进行轮询

问题描述 投票:0回答:1
@Bean
public HttpMessageHandlerSpec documentumPolledInbound() {
    return Http
        .outboundGateway("/fintegration/getReadyForReimInvoices/Cz", restTemplate)
        .expectedResponseType(String.class)
        .errorHandler(new DefaultResponseErrorHandler())
        ; 
}

如何轮询上面的内容,获取有效负载以便进一步处理

spring-integration spring-integration-dsl spring-integration-http
1个回答
2
投票

HTTP客户端端点不可轮询,但是事件驱动。因此,正如您通常从curl调用一些REST服务,例如,这里也会发生相同的情况。我想,你有一些.handle(),这个documentumPolledInbound()并且有一些消息通道发送消息来触发这个端点来调用你的REST服务。

不清楚你将如何处理响应,但有一种方法可以定期触发事件来调用此端点。

为此,我们只能* mock *一个可以配置一些触发器策略的入站通道适配器:

@Bean
public IntegrationFlow httpPollingFlow() {    
    return IntegrationFlows
                    .from(() -> "", e -> e.poller(p -> p.fixedDelay(10, TimeUnit.SECONDS)))
                    .handle(documentumPolledInbound())
                    .get();
}

这样我们就会发送一个带有空字符串作为有效负载的消息到handle()的通道。我们每隔10秒就这样做。

由于你的HttpMessageHandlerSpec并不关心入站有效载荷,因此我们从轮询通道适配器中的MessageSource返回的内容并不重要。

© www.soinside.com 2019 - 2024. All rights reserved.