Skip to content

Instantly share code, notes, and snippets.

@bforrest
Created May 28, 2020 17:38
Show Gist options
  • Save bforrest/8ba00354022da1d7d4253ee0e54d5c09 to your computer and use it in GitHub Desktop.
Save bforrest/8ba00354022da1d7d4253ee0e54d5c09 to your computer and use it in GitHub Desktop.
Masstransit-schedule-timeout
var configuredDelay = TimeSpan.FromMinutes(30);
Schedule( () => ActivityCompletionTimeout,
instance => instance.ActivityCompletionTimeoutTokenId,
s =>
{
s.Delay = configuredDelay;
s.Received = r => r.CorrelateById(context => context.Message.SagaId);
});
During(Initial,
When(Start)
.Activity(x => x.OfType<Activity>())
.TransitionTo(NextState)
.Execute( context => new PublishNextCommand(howMany))
.Schedule(ActivityCompletionTimeout,
ctx => ctx.Init<ActivityCompletionTimeoutExpired>(
new {
SagaId = ctx.Instance.CorrelationId,
ctx.Instance.CorrelationId,
CommandName = nameof(PublishNextCommand)
}
)
, ctx => configuredDelay)); // Thought this would set the timeout for the ActivityCompletionTimeout to 30 minutes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment