Guru
Guru

Reputation: 2857

Poll on HttpOutboundGateway

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

How to poll the above, to get the payload for further processing

Upvotes: 0

Views: 128

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121177

The HTTP Client endpoint is not pollable, but event-driven. So, as you usually call some REST Service from the curl, for example, the same way happens here. You have some .handle(), I guess, for this documentumPolledInbound() and there is some message channel to send message to trigger this endpoint to call your REST service.

Not clear how you are going to handle a response, but there is rally a way to trigger an event periodically to call this endpoint.

For that purpose we only can * mock* an inbound channel adapter which can configured with some trigger policy:

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

This way we are going to send a message with an empty string as a payload to the channel for the handle(). And we do that every 10 seconds.

Since your HttpMessageHandlerSpec doesn't care about an inbound payload, it is really doesn't matter what we return from the MessageSource in the polling channel adapter.

Upvotes: 2

Related Questions