In MassTransit if I set a TTL for a scheduled message, is the initial delay included?

有些话、适合烂在心里 提交于 2021-01-29 21:20:48

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/65128514/in-masstransit-if-i-set-a-ttl-for-a-scheduled-message-is-the-initial-delay-incl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!