2016-07-15 54 views
2

我有以下类:Spring集成:@ServiceActivator不工作

@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”,我得到的跟随着消息:

osiw SimpleWebServiceInboundGateway - 在网关sendAndReceive中发生故障:分派器没有用于频道'org.springframework.web.context.WebApplicationContext:/ MyProject restful API.testChannel'的订阅者。嵌套的异常是org.springframework.integration.MessageDispatchingException:调度员没有订户

我在做什么错?

回答

4

您需要将@EnableIntegration添加到您的某个配置类中。

0

将调度程序添加到testChannel将解决此问题。