alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.91k stars 8.33k forks source link

RocketMQ Message hasn't been sent. Caused by Send [1] times, still failed, cost [xxx]ms #1489

Open 2507007808 opened 4 years ago

2507007808 commented 4 years ago

Spring Cloud Stream + RocketMQ 发送消息失败

错误描述 RocketMQMessageHandler : RocketMQ Message hasn't been sent. Caused by Send [1] times, still failed, cost [xxx]ms

  1. 导入Stream依赖

    com.alibaba.cloud spring-cloud-starter-stream-rocketmq
  2. 在SpringBootApplication中声明 @EnableBinding(Source.class)

  3. 使用Source发送消息 @Autowired private Source source;

String payload = "This is Payload"; boolean success = source.output().send(MessageBuilder.withPayload(payload).build());

  1. 原因分析 发送的返回结果success是true, 但实际发送是失败的,跟踪代码发现原因是RocketMQProducerProperties类的vipChannelEnabled默认属性为true,一般搭建的RocketMQ服务该值默认为false,所以发送失败并抛出异常RocketMQ Message hasn't been sent,建议将该类默认值设置为false

5、临时解决方案添加yaml文件的vipChannelEnabled默认值为false spring: cloud: stream: rocketmq: default: producer: vipChannelEnabled: true binder: name-server: xxx.xxx.xxx.xxx

备注 :环境配置 jdk 1.8 rocketmq-spring-boot-starter 2.0.3 spring-cloud-starter-stream-rocketmq Version 2.2.1.RELEASE RocketMQ 4.5.1

fangjian0423 commented 4 years ago

Refer https://github.com/apache/rocketmq/blob/master/client/src/main/java/org/apache/rocketmq/client/ClientConfig.java#L59, the default value of vipChannelEnabled is false.

BTW, earlier version the default value of vipChannelEnabled is true.

fangjian0423 commented 4 years ago

could you please help to upgrade rockemq client version and modify the default value of vipChannelEnabled?