2016-07-15 238 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將解決此問題。