【问题标题】:Spring Integration - Get info from 3rd party services using replyChannelSpring Integration - 使用 replyChannel 从 3rd 方服务获取信息
【发布时间】:2017-08-03 13:53:01
【问题描述】:

我是 Spring Integration 新手,我必须从 3rd 方 Web 服务获取在线代理列表,我尝试配置 Spring Integration 来获取它,但对于 channel 部分,我不太确定如何配置它.

我的原始配置如下,我从用于向 3rd 方 Web 服务发送请求的示例中复制:

public interface WebServiceGateway {

    @Gateway(requestChannel = "getStatusChannel")
    public String getStatus(String var);     <------ being forced to send something
}

在我的集成配置中,

@Configuration
public class IntegrationConfiguration {

   @Bean
    public MessageChannel getStatusChannel() {
        return MessageChannels.direct().get();
    }
}

问题是,我没有向网络服务发送任何参数,在requestChannel 它迫使我这样做,所以我修改了gateway 部分:

public interface WebServiceGateway {

    @Gateway(replyChannel = "getStatusChannel")
    public String getStatus();
}

这部分保持不变:

@Configuration
public class IntegrationConfiguration {

   @Bean
    public MessageChannel getStatusChannel() {
        return MessageChannels.direct().get();
    }
}

提示我java.lang.IllegalStateException: receive is not supported, because no pollable reply channel has been configured,为什么我不能使用MessageChannel作为回复频道?我应该如何配置IntegrationConfiguration

【问题讨论】:

    标签: java spring web-services spring-integration-dsl


    【解决方案1】:

    请通过这个https://spring.io/blog/2014/11/25/spring-integration-java-dsl-line-by-line-tutorial

    您只需要定义一个如下所示的IntegrationFlow:

    IntegrationFlows.from(requestchannel())
                    .handle("requestHandler","handleInput")
                    .channel(replyChannel())            
                    .get();
    

    【讨论】:

      猜你喜欢
      • 2023-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多