java - Spring 集成: @ServiceActivator is not working

标签 java spring spring-integration

我有以下类(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;
    }

}

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

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

我做错了什么?

最佳答案

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

关于java - Spring 集成: @ServiceActivator is not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38397185/

相关文章:

java - 无法从 Throwable 转换为 MyException

mysql - 如何在 Spring Security 登录表单中传递一个附加参数

java - Spring Integration - 文件写入操作的服务参与者抛出错误

java - Camel HTTP 的截断响应

spring-integration - 使用 spring-integration java dsl .publishSubscribeChannel() 或 channel()?

带 @Async 注解的 Spring SimpleAsyncTaskExecutor 和 ThreadPoolTask​​Executor

java - AsynchronousFileChannel中的CompletionHandler读取数据有什么用?

java - 如何从 javaFx 中同一数据库中的两个 mysql 表填充 TableView ?

java - java RandomUtils 需要包含什么?

java - Spring Security 中用于身份验证的模拟对象