spring-integration-java-dsl channel creation

时间:2014-12-01 11:40:45

标签: spring-integration

doc说:如果没有具有此名称的bean,将在上下文启动时创建新的DirectChannel bean。

 @MessagingGateway
    public interface Responder {

        @Gateway(requestChannel = "request.input")
        String respond(String request);

    }

    @Bean
    public IntegrationFlow doResponse(){

        return IntegrationFlows
            .from("request.input")
            .transform("payload")
            .get();

    }

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {IntegrationConfiguration.class})
public class GatewayTests {

    @Autowired Responder responder;

    @Test
    public void test(){

        responder.respond("request");

    }

}

这导致:没有名为“request.input'被定义为 我有什么东西可以触发创建频道吗?

spring-boot:1.1.9.RELEASE spring-integration-java-dsl:1.0.0.RELEASE spring-integration:4.0.4.RELEASE

1 个答案:

答案 0 :(得分:3)

您应该确保Spring Integration基础架构在@EnableIntegration类上进行了@Configuration,如果您使用Spring Boot,则应该@EnableAutoConfiguration

从另一方面来看,并非所有auto-channel功能都适用于Spring Integration 4.0.x。

通过明确的MessageChannel @Bean,您始终可以克服这个问题。