Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

设置延时发送时,msgId 不一致 #24

Closed
clChenLiang opened this issue Jan 23, 2018 · 6 comments
Closed

设置延时发送时,msgId 不一致 #24

clChenLiang opened this issue Jan 23, 2018 · 6 comments
Labels

Comments

@clChenLiang
Copy link

使用过程中发送,在 Message含有 delay 参数的情况下,消费者和生产者各自获取到的 msgId 不一致!
测试代码如下:

'use strict';
const co = require('co');
const producer = require('./alionsProducer');

co(function *() {
    for (let i = 0; i < 15; i++) {
        // co(producer.send({ a: 1, b: 2 }, {
        //     delay: i,
        // }));
        let result = yield producer.send({a:i,b:2}, {
            delay: i
        });
        console.log(`第 ${i} 次:${JSON.stringify(result)}`);
    }
});

如果将 delay: i 换成 delay: 0 则接收到的 msgId 一致
send 是对 producer 封装的一个代码:

function *send(content, options) {
        let msg = new Message(
        options.topic || 'Message_test_11',
        options.tag || '*',
        JSON.stringify(content)
    );

    if(options.delay) {
        msg.delayTimeLevel = options.delay;
    }
   
    let result = yield producer.send(msg);
    return result;
}
@clChenLiang
Copy link
Author

可以参考使用:
msg.properties.UNIQ_KEY 方法获取

@clChenLiang
Copy link
Author

请问 msg.properties 属性是由 阿里云 MQ 服务器确定的吗?

@gxcsoccer
Copy link
Contributor

这个功能我没用过。。

@denghongcai
Copy link
Collaborator

延时消息是两条消息

Broker先将消息的 消息的 topic 改成 “SCHEDULE_TOPIC_XXXX”,并把真正的Topic保存在消息的 REAL_TOPIC 属性中。时间到了之后,会将它捞出来,恢复Topic, 并开始写 CommitLog 和 ConsumeQueue。

msg.properties broker 是可能修改的,或者你发送的时候往 msg 里添加也行

@gxcsoccer
Copy link
Contributor

@denghongcai 所以这是正常的了? 这个功能我们貌似没有刻意支持?

@denghongcai
Copy link
Collaborator

@gxcsoccer

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants