轮询HttpOutboundGateway

时间:2019-03-16 16:58:42

标签: spring-integration spring-integration-dsl spring-integration-http

@Bean
public HttpMessageHandlerSpec documentumPolledInbound() {
    return Http
        .outboundGateway("/fintegration/getReadyForReimInvoices/Cz", restTemplate)
        .expectedResponseType(String.class)
        .errorHandler(new DefaultResponseErrorHandler())
        ; 
}

如何轮询以上内容,以获取有效载荷以进行进一步处理

1 个答案:

答案 0 :(得分:2)

HTTP客户端端点不是可轮询的,而是事件驱动的。因此,例如,通常您从node_modules调用REST服务时,此处也会发生相同的情况。我猜您为此sam build有一些curl,并且有一些消息通道可以发送消息以触发此终结点来调用REST服务。

不清楚您将如何处理响应,但是有一种方法可以周期性地触发事件以调用此端点。

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

.handle()

这样,我们将向空documentumPolledInbound()的通道发送一条带有空字符串的消息作为有效载荷。而且我们每10秒钟执行一次。

由于您的@Bean public IntegrationFlow httpPollingFlow() { return IntegrationFlows .from(() -> "", e -> e.poller(p -> p.fixedDelay(10, TimeUnit.SECONDS))) .handle(documentumPolledInbound()) .get(); } 不在乎入站有效负载,因此从轮询通道适配器中的handle()返回的内容实际上并不重要。