使用Spring Cloud Stream编写生产者时,注入的Source为null
来源:9-15 Spring Cloud Stream-编写生产者

kkthmyh
2020-11-05
老师您好:
@GetMapping("test-stream")
public String testStream() {
this.source.output().send(MessageBuilder.withPayload("消息体").build());
return "200";
}
这里注入的Source为null,启动类确认加了@EnableBinding({Source.class}),希望可以解答疑惑
3回答
-
精慕门3084555
2020-12-23
我也遇到这个问题了,消息发送不了,
23:13:01.377 ERROR 19816 --- [enderExecutor_3] c.a.c.s.b.r.i.RocketMQMessageHandler : RocketMQ Message hasn't been sent. Caused by Send [1] times, still failed, cost [3003]ms, Topic: stream-test-topic, BrokersSent: [broker-a]
See http://rocketmq.apache.org/docs/faq/ for further details.
控制台也没有stream-test-topic 这个主题,请问下是如何解决的
022020-12-24 -
大目
2020-11-06
如果你对原理感兴趣,可以这样:
把代码改成如下:
2. 在org.springframework.cloud.stream.binding.BindableProxyFactory#invoke 方法上打上断点
3. 访问/test-stream断点,触发source.toString方法。然后你会发现,这个toString()方法是拿不到的,直接返回了null。
00 -
大目
2020-11-05
您好,从您贴出的代码来看,是OK的,一时之间我也不知道是什么问题。
建议将完整的代码共享到GitHub或者Gitee,我来给你看看吧。
032020-11-06
相似问题