Spring Integration - 使用replyChannel

时间:2017-08-03 02:36:03

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

我是Spring Integration的新手,我必须从第三方Web服务获得一个在线代理列表,我试图配置spring集成来获取它,但对于channel部分,我不确定如何配置它。

我的原始配置如下,我从用于发送请求的示例复制到第三方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();
    }
}

问题是,我没有向web服务发送任何参数,在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

1 个答案:

答案 0 :(得分:0)

请完成此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();