当前位置: 首页 > 知识库问答 >
问题:

Spring集成配置错误:Dispatcher没有订阅者

史弘博
2023-03-14

您可以帮助进行spring集成配置吗。

收到消息后,我收到:

org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'myapp-1.scMyRequestChannel'.; nested exception is org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers, failedMessage=GenericMessage [payload=input me, headers={JMS_IBM_Character_Set=UTF-8, errorChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@6c7a1290, JMS_IBM_MsgType=8, jms_destination=queue:///SYN.REQ, JMSXUserID=mqm         , JMS_IBM_Encoding=273, priority=4, jms_timestamp=1590129774770, JMSXAppID=hermes.browser.HermesBrowser, JMS_IBM_PutApplType=28, JMS_IBM_Format=MQSTR   , replyChannel=org.springframework.messaging.core.GenericMessagingTemplate$TemporaryReplyChannel@6c7a1290, jms_redelivered=true, JMS_IBM_PutDate=20200522, JMSXDeliveryCount=649, JMS_IBM_PutTime=06425480, id=ed13c600-56b5-33ff-7228-0a5d146b618b, jms_messageId=ID:414d5120514d31202020202020202020aa6fc75e004d3e12, timestamp=1590135772781}]
    at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77) ~[spring-integration-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:453) ~[spring-integration-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:187) ~[spring-messaging-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:233) ~[spring-messaging-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.messaging.core.GenericMessagingTemplate.doSendAndReceive(GenericMessagingTemplate.java:47) ~[spring-messaging-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.messaging.core.AbstractMessagingTemplate.sendAndReceive(AbstractMessagingTemplate.java:46) ~[spring-messaging-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:97) ~[spring-integration-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:499) ~[spring-integration-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:470) ~[spring-integration-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.integration.jms.ChannelPublishingJmsMessageListener$GatewayDelegate.sendAndReceiveMessage(ChannelPublishingJmsMessageListener.java:511) ~[spring-integration-jms-5.1.2.RELEASE.jar:5.1.2.RELEASE]
    at org.springframework.integration.jms.ChannelPublishingJmsMessageListener.onMessage(ChannelPublishingJmsMessageListener.java:344) ~[spring-integration-jms-5.1.2.RELEASE.jar:5.1.2.RELEASE]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:736) ~[spring-jms-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:696) ~[spring-jms-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:674) ~[spring-jms-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:318) [spring-jms-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:257) [spring-jms-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1189) [spring-jms-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1179) [spring-jms-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1076) [spring-jms-5.1.7.RELEASE.jar:5.1.7.RELEASE]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_201]

我的代码:

@Configuration
public class MyEndpointConfiguration {
    public static final String SC_My_REQUEST_CHANNEL = "scMyRequestChannel";
    public static final String SC_My_RESPONSE_CHANNEL = "scMyResponseChannel";

    @Bean
    public MessageChannel scMyRequestChannel() {
        return new DirectChannel();
    }

    @Bean
    public MessageChannel scMyResponseChannel() {
        return new DirectChannel();
    }

    @Bean
    public MessageConverter myMessageConverter() {
        return new MyMessageConverter();
    }

    @Bean
    JmsInboundGateway myJmsInboundGateway(ConnectionFactory myConnectionFactory,
                                           MessageConverter myMessageConverter,
                                           MessageChannel scMyRequestChannel,
                                           MessageChannel scMyResponseChannel,
                                           Destination myScRequestDestination,
                                           Destination myScResponseDestination) {
        return Jms
                .inboundGateway(myConnectionFactory)
                .destination(myScRequestDestination)
                .defaultReplyDestination(myScResponseDestination)
                .requestChannel(scMyRequestChannel)
                .replyChannel(scMyResponseChannel)
                .jmsMessageConverter(myMessageConverter)
                .get();
    }

    public IntegrationFlow getFromConvertAndPutToSpring(JmsInboundGateway myJmsInboundGateway) {
        return IntegrationFlows
                .from(myJmsInboundGateway)
                .handle((p,h) -> "my answer")
                .logAndReply("inbound");
    }

//    public IntegrationFlow getFromInputChannel(MessageChannel scMyRequestChannel) {
//        return IntegrationFlows
//                .from(scMyRequestChannel)
//                .log("sc input")
//                .handle((p,h) -> "my answer")
//                .log()
//                .nullChannel();
//    }
}

我有类似的JmsInboudGateway配置,用于其他没有.requestChannel和.replyChannel的队列。

如果不是注入请求通道bean,而是用文本名称声明它,得到了这个

org.springframework.messaging.MessagingException: No request channel available. Cannot send request message.
    at org.springframework.integration.gateway.MessagingGatewaySupport.doSendAndReceive(MessagingGatewaySupport.java:479) ~[spring-integration-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.integration.gateway.MessagingGatewaySupport.sendAndReceiveMessage(MessagingGatewaySupport.java:470) ~[spring-integration-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
    at org.springframework.integration.jms.ChannelPublishingJmsMessageListener$GatewayDelegate.sendAndReceiveMessage(ChannelPublishingJmsMessageListener.java:511) ~[spring-integration-jms-5.1.2.RELEASE.jar:5.1.2.RELEASE]

以及更多的文字宣传问题。

共有1个答案

狄旻
2023-03-14

抱歉,在测试过程中,我似乎错过了Bean注释。

 类似资料:
  • 我的应用程序成功发送Kafka消息,但只有在Kafka初始化后。在此之前,我得到错误“Dispatcher没有订阅者”。如何等待订阅者完成频道注册? 17.165 SenderClass已创建 17.816初始化类,@PostConstruct启动PollingTask 24.781PollingTask发送第一条Kafka消息 24.816第一个错误:“Dispatcher没有订阅服务器” 25

  • 我为使用spring cloud starter stream rabbit编写了一个测试类,当我只运行receiver并从rabbitmq发送消息时,它可以工作;但是当我运行test sender类时,出现了一个错误:

  • 我正在尝试实现Spring与MQTT的集成。我正在使用Mosquitto作为MQTT经纪人。并在下面的链接中提供了文档的引用。我已经创建了一个项目并添加了所有所需的jar文件。当我执行时。 当我通过MQTT代理发布消息时,我收到以下错误。 添加@SpringBootApplication注释后,请找到下面的堆栈跟踪

  • 我是Spring MVC的新手,正在尝试在Spring MVC中创建我的第一个项目。请帮助我解决以下错误:- 控制台中出现以下错误:- web.xml dispatcher-servlet.xml 控制器类别 索引1.jsp Eclipse项目层次结构

  • 试图在Web应用程序中提供自定义404错误页面,据我所知,该应用程序使用Java配置(因此没有web.xml)。 我们有以下版本的相关库:Spring("5.1.2. RELEASE")、sping-Security("5.1.1. RELEASE")。 我在StackOverflow中检查了这里的不同方法。请不要建议web.xml、Thymeleaf或Spring Boot的结果。这不适用。 其

  • 我已经完成了以下配置和java代码,以向Kafka主题发送消息。我只想发信息。 我正在使用Spring boot和kafka集成 Kafka应用程序已从Docker启动 Spring Boot应用程序通过简单的配置连接kafka 波姆。xml 应用yml 消息通道Bean 日志事件发布程序 Restendpoint发布消息 下面是我在执行其余endpoint时得到的异常跟踪。