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.97k stars 8.34k forks source link

spring-cloud-starter-stream-rocketmq期望支持阿里云RocketMQ定时消息(不是延时消息) #791

Open jojozoo opened 5 years ago

jojozoo commented 5 years ago

现象:使用ONS连接阿里云RocketMq,可支持阿里云RocketMQ定时消息(不是延时消息) ,使用rocketmq stream binder则不能支持,只能支持到延时消息 。

jojozoo commented 5 years ago

https://help.aliyun.com/document_detail/43349.html?spm=a2c4g.11186631.6.552.20227ea1qoLgio

Nitsuya commented 5 years ago

是支持的 头信息传入 [__STARTDELIVERTIME]: 指定时间

Nitsuya commented 5 years ago

DefaultMQProducerImpl 的 739行... 不知道为啥官方不在加个header的key~

jojozoo commented 5 years ago

__STARTDELIVERTIME 设过了然而不起作用

fangjian0423 commented 5 years ago

RocketMQ Binder 现在只支持 DELAY 这个 header

jojozoo commented 5 years ago

DELAY 这个header 在开源的RocketMq是可以用 但是在阿里云RocketMq 也是起不了作用!

jojozoo commented 5 years ago

期望尽早支持这个特性

Nitsuya commented 5 years ago

@jojozoo 开源是Delay 传入等级,阿里云是__STARTDELIVERTIME 传入指定时间,阿里云上面必须建延迟topic,不是普通类型。。 目前正在用。。。

jojozoo commented 5 years ago

可以发个示例代码?

jojozoo commented 5 years ago
    Message<String> msgBody = MessageBuilder
            .withPayload("12345")
            .setHeader("__STARTDELIVERTIME", "2019-07-31 15:20:01")
            .build();
jojozoo commented 5 years ago

@Nitsuya 可以发个示例代码?

Nitsuya commented 5 years ago

@jojozoo 就是你发的这样,走的topic要走阿里云的延迟topic。 我用的 版本0.9.0

jojozoo commented 5 years ago

我这边死活不成功 怎么设置都是死活延时1分30秒左右

jojozoo commented 5 years ago

@fangjian0423 能做个官方demo?

fangjian0423 commented 5 years ago

@jojozoo

image

image

image

producer code snipper:

Message msg = MessageBuilder.withPayload("simple msg")
                .setHeader("DELAY", 3).build();
source.output().send(msg);
System.out.println("msg send at " + DateFormatUtils
        .format(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));

configurations:

spring.cloud.stream.rocketmq.binder.name-server=nameServerInAliwareMQ
spring.cloud.stream.rocketmq.binder.access-key=ak
spring.cloud.stream.rocketmq.binder.secret-key=sk

spring.cloud.stream.bindings.output.destination=instanceId%test-topic
spring.cloud.stream.bindings.output.content-type=application/json
spring.cloud.stream.rocketmq.bindings.output.producer.sync=true
fangjian0423 commented 5 years ago

need __STARTDELIVERTIME header

jojozoo commented 5 years ago

@Nitsuya DefaultMQProducerImpl 的 739行... 不知道为啥官方不在加个header的key~ https://github.com/apache/rocketmq/blob/8e44ca1ff1c8a8c3513cc88087c83db04973a47a/client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java#L739 这里要加什么

jojozoo commented 5 years ago

need __STARTDELIVERTIME header

Nitsuya commented 5 years ago

@jojozoo
这里不加东西啊。 你发的这个链接是 752行,开源版本是写死的。。 我的意思是为啥开源版本不加个header,干嘛在里面写死的。


正确的例子是这样的:
`
setHeader("__STARTDELIVERTIME", new Date().getTime() + 你要延迟的毫秒)
`
jojozoo commented 5 years ago

@Nitsuya 我这边测试成功了 就是云上控制台上消息查询不出了

Nitsuya commented 5 years ago

@jojozoo https://github.com/alibaba/spring-cloud-alibaba/issues/764#issue-469548964

shandianzhao commented 4 years ago

@fangjian0423 按照你的配置使用output默认Source是可以的。但是自定义source跟源码sync源码未赋值 比如:spring.cloud.stream.rocketmq.bindings.expresstimeout.producer.sync=true

tongYP commented 3 years ago

不能与Nacos 配置中心一起使用,Cannot find '.class' file for class [class com.alibaba.cloud.stream.binder.rocketmq.config.RocketMQBinderAutoConfiguration$$EnhancerBySpringCGLIB$$7edca4c6] - unable to determine constructor/method parameter names,导致无法加载配置

zkzlx commented 3 years ago

please try the beta version #2029 to see if it solves your problem, or provide us more information to help find the latent bug.