Почему Spring Integration Java DSL-запрос для JSON не работает - PullRequest
0 голосов
/ 27 сентября 2018

У меня есть определение bean-компонента

    @Bean
public IntegrationFlow inbound() {
    return IntegrationFlows.from(MessageChannels.queue("getSend1"))
            .handle(Http.outboundGateway("http://localhost:8055/greeting").httpMethod(HttpMethod.GET)
                    .expectedResponseType(String.class))
            .channel(MessageChannels.queue("getReceive1"))
            .get();
}

и опросник по умолчанию, и я хочу получить JSON из URL.Это не работает.Услуга http://localhost:8055/greeting вообще не вызывается, и выводится лог-сообщение

preReceive on channel 'getSend1'
postReceive on channel 'getSend1', message is null
Received no Message during the poll, returning 'false'

.

1 Ответ

0 голосов
/ 27 сентября 2018

Это работает так:

    @Bean
public IntegrationFlow inbound() {
    return IntegrationFlows
            .from(this.integerMessageSource(), c -> c.poller(Pollers.fixedRate(2000)))
            .handle(Http.outboundGateway("http://localhost:8055/greeting")
                    .httpMethod(HttpMethod.GET).expectedResponseType(String.class))
            .channel(MessageChannels.queue("getReceive"))
            .handle(Http.outboundGateway("http://localhost:8055/greeting").httpMethod(HttpMethod.POST)
                    .expectedResponseType(String.class))
            .channel(MessageChannels.queue("postReceive"))
            .handle(Http.outboundGateway("http://localhost:8055/greeting-final").httpMethod(HttpMethod.POST)
                    .expectedResponseType(String.class))
            .channel(MessageChannels.queue("postReceiveFinal"))
            .get();
}

Это действительно для первого URL, затем отправляет ответ на второй URL, а затем отправляет ответ на третий URL и получает окончательный ответ.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...