spring cloud stream 使用rabbitmq 发送消息时 发送通道异常

发布于 2022-09-05 07:34:23 字数 2434 浏览 8 评论 0

在使用Spring-cloud=stream时,配置如下

### boot setting
server.port=9002
### stream setting

### push channel
spring.cloud.stream.bindings.push_sender.destination=push_receiver
spring.cloud.stream.bindings.push_sender.content-type=application/json

### push channel
spring.cloud.stream.bindings.push_recevier.destination=push_return
spring.cloud.stream.bindings.push_recevier.content-type=application/json
spring.cloud.stream.bindings.push_recevier.group=push




#spring.cloud.stream.bindings.return.destination=push
#spring.cloud.stream.bindings.return.content-type=application/json

### rabbit setting
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=demo
spring.rabbitmq.password=123456

然后通道如下

package com.inlee.message.main.msgInterface;

import org.springframework.cloud.stream.annotation.Output;
import org.springframework.messaging.MessageChannel;

public interface MessageOut {
    
    String PUSH = "push_sender";
    String SMS = "sms_sender";
    String CHALLENGE = "challenge_sender";
    String BIND = "bind_sender";
    
    @Output(MessageOut.PUSH)
    MessageChannel push();
    
    @Output(MessageOut.SMS)
    MessageChannel sms();

    @Output(MessageOut.CHALLENGE)
    MessageChannel challenge();

    @Output(MessageOut.BIND)
    MessageChannel bind();
}
package com.inlee.message.main.msgInterface;

import org.springframework.cloud.stream.annotation.Input;
import org.springframework.messaging.SubscribableChannel;

public interface MessageReturn {

    String PUSH_RECEVIER = "push_recevier";
    String BIND_RECEVIER = "bind_recevier";
    String SMS_RECEVIER = "sms_recevier";
    String CHALLENGE_RECEVIER = "challenge_recevier";
    
    @Input(MessageReturn.PUSH_RECEVIER)
    SubscribableChannel push();
    
    @Input(MessageReturn.SMS_RECEVIER)
    SubscribableChannel sms();
    
    @Input(MessageReturn.CHALLENGE_RECEVIER)
    SubscribableChannel challenge();
    
    @Input(MessageReturn.BIND_RECEVIER)
    SubscribableChannel bind();
    
}

发送时遇到如下情况

org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'application:9002.push_recevier'.; nested exception is org.springframework.integration.MessageDispatchingException: Dispatcher has no subscribers, 

正常的channel应该是push_recevier,但是不知道为什么自己加了application:9002
求解!
谢谢了!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

御弟哥哥 2022-09-12 07:34:23

你的类没有注入@Service 或者把@EnableBinding 从启动类放到你的接收消息的类上

你是我的挚爱i 2022-09-12 07:34:23

遇到同样的问题,请问你解决了么

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文