Spring Integration Dispatcher没有频道订阅者

Spring Integration Dispatcher没有频道订阅者,第1张

概述我正在使用spring集成及其对MQTT的支持;我看到了spring集成文档,我的简单测试用例是在MQTT主题上发布消息. Spring文档位于:http://docs.spring.io/spring-integration/reference/html/mqtt.html#_configuring_with_java_configuration_15我正

我正在使用spring集成及其对MQTT的支持;我看到了spring集成文档,我的简单测试用例是在MQTT主题上发布消息. Spring文档位于:http://docs.spring.io/spring-integration/reference/html/mqtt.html#_configuring_with_java_configuration_15

我正在使用这些版本:

>春天4.3.4
>春季整合4.3.5

我构建了这个简单的配置类:

@Configuration@IntegrationComponentScanpublic class CommunicationServerApplication{    @Bean    public MqttPahoClIEntFactory mqttClIEntFactory()    {        DefaultMqttPahoClIEntFactory factory = new DefaultMqttPahoClIEntFactory();        factory.setServerURIs(mqttServerUris);        if (StringUtils.hasText(mqttUsername) && StringUtils.hasText(mqttPassword))        {            factory.setUsername(mqttUsername);            factory.setPassword(mqttPassword);        }        factory.setConnectionTimeout(mqttConnectionTimeout);        factory.setKeepAliveInterval(mqttKeepAliveInterval);        factory.setPersistence(new MqttDefaultfilePersistence(mqttPersistencefileDirectory));        return factory;    }    @Bean    @ServiceActivator(inputChannel = "mqttOutboundChannel",autoStartup="true")    public MessageHandler mqttOutbound()    {        String clIEntID = mqttClIEntID;        if( !StringUtils.hasText(clIEntID) )        {            clIEntID = UUID.randomUUID().toString();        }        MqttPahoMessageHandler messageHandler = new MqttPahoMessageHandler(clIEntID,mqttClIEntFactory());        messageHandler.setAsync(true);        messageHandler.setDefaulttopic(mqtttopic);        if( mqttQos >= 0 && mqttQos <=2 )        {            messageHandler.setDefaultQos(mqttQos);        }        return messageHandler;    }    @Bean    public MessageChannel mqttOutboundChannel()    {        DirectChannel dc = new DirectChannel();        return dc;    }    @MessagingGateway(defaultRequestChannel = "mqttOutboundChannel")    public interface MqttMsgproducer    {        voID sendToMqtt(String data);    }}

然后我使用了这个简单的测试用例:

@ContextConfiguration(value ={ "classpath:app-ctx.xml"})@RunWith(SpringJUnit4ClassRunner.class)public class SimpleMqttTestSuite{    private static final Logger logger = LoggerFactory.getLogger(SimpleMqttTestSuite.class.getname());    @autowired    private MqttMsgproducer sender;    @Test    public voID startServertest()    {        try        {            sender.sendToMqtt("Hello");        }        catch (Exception e)        {            logger.error("Error",e);        }    }}

我的app-ctx.xml是:

执行简单测试,我遇到了这个错误:

2016-12-20 10:46:33,889 49967 [nioEventLoopGroup-3-1] ERROR - Errore org.springframework.messaging.MessageDeliveryException: dispatcher has no subscribers for channel 'org.springframework.context.support.GenericApplicationContext@2e6a8155.mqttOutboundChannel'.; nested exception is org.springframework.integration.MessagedispatchingException: dispatcher has no subscribers    at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:81) ~[spring-integration-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:423) ~[spring-integration-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:373) ~[spring-integration-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]    at org.springframework.messaging.core.GenericmessagingTemplate.doSend(GenericmessagingTemplate.java:115) ~[spring-messaging-4.3.4.RELEASE.jar:4.3.4.RELEASE]    at org.springframework.messaging.core.GenericmessagingTemplate.doSend(GenericmessagingTemplate.java:45) ~[spring-messaging-4.3.4.RELEASE.jar:4.3.4.RELEASE]    at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:105) ~[spring-messaging-4.3.4.RELEASE.jar:4.3.4.RELEASE]    at org.springframework.messaging.core.AbstractMessageSendingTemplate.convertAndSend(AbstractMessageSendingTemplate.java:143) ~[spring-messaging-4.3.4.RELEASE.jar:4.3.4.RELEASE]    at org.springframework.messaging.core.AbstractMessageSendingTemplate.convertAndSend(AbstractMessageSendingTemplate.java:135) ~[spring-messaging-4.3.4.RELEASE.jar:4.3.4.RELEASE]    at org.springframework.integration.gateway.MessagingGatewaySupport.send(MessagingGatewaySupport.java:375) ~[spring-integration-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]    at org.springframework.integration.gateway.GatewayProxyfactorybean.invokeGatewayMethod(GatewayProxyfactorybean.java:477) ~[spring-integration-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]    at org.springframework.integration.gateway.GatewayProxyfactorybean.doInvoke(GatewayProxyfactorybean.java:429) ~[spring-integration-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]    at org.springframework.integration.gateway.GatewayProxyfactorybean.invoke(GatewayProxyfactorybean.java:420) ~[spring-integration-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]    at org.springframework.integration.gateway.GatewayCompletableFutureProxyfactorybean.invoke(GatewayCompletableFutureProxyfactorybean.java:65) ~[spring-integration-core-4.3.5.RELEASE.jar:4.3.5.RELEASE]    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.4.RELEASE.jar:4.3.4.RELEASE]    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.4.RELEASE.jar:4.3.4.RELEASE]

我无法想象我在配置中缺少什么.任何人都可以给我一个提示吗?

谢谢

安杰洛

最佳答案您的解决方案不正确 – 您不能在通道bean定义中订阅.我相信你的问题是你在课堂上缺少@EnableIntegration. 总结

以上是内存溢出为你收集整理的Spring Integration Dispatcher没有频道订阅者全部内容,希望文章能够帮你解决Spring Integration Dispatcher没有频道订阅者所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1267235.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)