我有以下课程:

@Configuration
public class SpringIntegrationTest {

    @Bean
    public SimpleWebServiceInboundGateway testInboundGateWay (){
        SimpleWebServiceInboundGateway simpleWebServiceInboundGateway = new SimpleWebServiceInboundGateway();
        simpleWebServiceInboundGateway.setRequestChannelName("testChannel");
        simpleWebServiceInboundGateway.setReplyChannelName("testChannel2");
        return simpleWebServiceInboundGateway;
    }

    @Bean
    public MessageChannel testChannel() {
        return new DirectChannel();
    }

    @Bean
    public MessageChannel testChannel2() {
        return new DirectChannel();
    }

    @ServiceActivator(inputChannel = "testChannel", outputChannel = "testChannel2")
    public DOMSource foo(DOMSource request) {
        System.out.println("asd");
        return request;
    }

    @Bean
    public EndpointMapping soapActionEndpointMapping(SimpleWebServiceInboundGateway testInboundGateWay ) {
        UriEndpointMapping uriEndpointMapping = new UriEndpointMapping();
        uriEndpointMapping.setUsePath(true);
        uriEndpointMapping.setEndpointMap(createEndpointMapping(testInboundGateWay ));
        return uriEndpointMapping;
    }

    private Map<String, Object> createEndpointMapping(SimpleWebServiceInboundGateway testInboundGateWay ) {
        Map<String, Object> endpointMap = new HashMap<>();
        endpointMap.put("/ws/test", testInboundGateWay );
        return endpointMap;
    }

}


即使服务激活器订阅了“ testChannel”,我仍然收到以下消息:


  o.s.i.w.SimpleWebServiceInboundGateway-网关sendAndReceive中发生故障:分派器没有频道“ org.springframework.web.context.WebApplicationContext:/ MyProject restful API.testChannel”的订阅者。嵌套的异常是org.springframework.integration.MessageDispatchingException:调度程序没有订阅者


我究竟做错了什么?

最佳答案

您需要将@EnableIntegration添加到配置类之一。

07-24 09:33