I have the following class:
@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;
}
}
Even tough the service activator is subscribed for the "testChannel", I get the followin message:
o.s.i.w.SimpleWebServiceInboundGateway - failure occurred in gateway sendAndReceive: Dispatcher has no subscribers for channel 'org.springframework.web.context.WebApplicationContext:/MyProject restful API.testChannel'.; nested exception is org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers
What am I doing wrong?
You need to add
@EnableIntegration
to one of your configuration classes.Adding a dispatcher to the testChannel would fix this issue.