问题
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