Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
899 views
in Technique[技术] by (71.8m points)

rabbitmq 延时消息 计时不准确 是什么原因?

这是go 写的一个延时处理的考试收卷延时消息
rabbitmq已安装了延时消息插件
examRecord.MyExamination.AnswerTime = 120 分钟

`delayInt := function.GenerateRangeNum(10, 100) //这是一个随机数 71
ExpireTime := strconv.FormatInt(examRecord.MyExamination.AnswerTime601000+int64(delayInt)*1000, 10)
logger.Log(logger.InfoLevel,delayInt)// 值为71
logger.Log(logger.InfoLevel,ExpireTime)// 值为 7271000
body, _ := proto.Marshal(resp.ExamRecord)
if err := h.Broker.Publish(AutomaticHandingInTopic, &broker.Message{
// "delay": ExpireTime 兼容阿里云AMQP
Header: map[string]string{"x-delay": ExpireTime, "delay": ExpireTime},
Body: body,
}, rabbitmq.DeliveryMode(2)); err != nil {
resp.Error = &pb.Error{Description: err.Error()}
}`

以上代码执行后 rabbitmq 会提前几十秒钟执行了,正常应该是7271秒后才执行呀,是因为rabbitmq计时不准确吗?还是什么原因,感觉时间越长,误差就越大,几分钟的时候没有这个情况。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...