【问题标题】:Why Spring Integration Java DSL request for the JSON is not working为什么对 JSON 的 Spring Integration Java DSL 请求不起作用
【发布时间】:2018-09-27 05:22:25
【问题描述】:

我有 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();
}

和默认轮询器,我想从 URL 中获取 JSON。这是行不通的。服务http://localhost:8055/greeting根本没有被调用和日志消息

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

被打印出来了。

【问题讨论】:

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


    【解决方案1】:

    它是这样工作的:

        @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 并获得最终答案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-10
      相关资源
      最近更新 更多