gpt4 book ai didi

java - Spring 集成 : @ServiceActivator is not working

转载 作者:行者123 更新时间:2023-11-30 06:52:49 24 4
gpt4 key购买 nike

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

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com