在MassTransit中,如果我为预定消息设置了TTL,是否包括初始延迟?

编程入门 行业动态 更新时间:2024-10-11 21:23:41
本文介绍了在MassTransit中,如果我为预定消息设置了TTL,是否包括初始延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在MassTransit中,如果我计划将来发送一条消息(比方说3天之内),并且我将消息的TTL设置为1天,那么该消息的实际TTL是否为4天?>

如果我将消息安排在将来的30天,则倾向于将TTL设置为30 + 1天,但是我不想这样做,以防我又不知道又增加了30天的TTL的.

解决方案

从查看 MassTransit存储库,似乎TTL应用于消息发送,而不是消息创建时:

if(context.TimeToLive.HasValue)transportMessage.NMSTimeToLive = context.TimeToLive>TimeSpan.Zero?context.TimeToLive.Value:TimeSpan.FromSeconds(1);...var publishTask = Task.Run(()=> producer.Send(transportMessage),context.CancellationToken);

因此,您应该将发布时间设置为1天,直到发送邮件之前不考虑TTL.

In MassTransit, if I schedule a message to be delivered in the future (let's say in 3 days), and I set a TTL on the message for 1 day, is the actual TTL for the message then 4 days?

If I schedule a message 30 days in the future, I'm tempted to set the TTL to 30 + 1 days, but I don't want to do that in case that adds another 30 days of TTL that I am unaware of.

解决方案

From looking at the MassTransit repository, it seems like the TTL is applied upon the message being sent, rather than when it was created:

if (context.TimeToLive.HasValue) transportMessage.NMSTimeToLive = context.TimeToLive > TimeSpan.Zero ? context.TimeToLive.Value : TimeSpan.FromSeconds(1); ... var publishTask = Task.Run(() => producer.Send(transportMessage), context.CancellationToken);

So should you set your publish time to be 1 day, until the message is sent the TTL is not considered.

更多推荐

在MassTransit中,如果我为预定消息设置了TTL,是否包括初始延迟?

本文发布于:2023-10-18 15:12:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504600.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:我为   消息   MassTransit   TTL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!