2016-07-15 3 views
2

У меня есть следующий класс:Spring Integration: @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", я получаю followin сообщение:

osiw SimpleWebServiceInboundGateway - произошел сбой в шлюзе sendAndReceive: у диспетчера нет подписчиков для канала 'org.springframework.web.context.WebApplicationContext:/MyProject restful API.testChannel' .; Вложенное исключение - org.springframework.integration.MessageDispatchingException: у диспетчера нет подписчиков

Что я делаю неправильно?

ответ

4

Вам необходимо добавить @EnableIntegration в один из классов конфигурации.

0

Добавление диспетчера в testChannel устранит эту проблему.

Смежные вопросы