Skip to content

Saga Activity Exception Handler and Set Retry Policy #5194

Answered by phatboyg
muratyuceer asked this question in Q&A
Discussion options

You must be logged in to vote
Initially(
    When(CreateOrderRequest)
        .Then(context =>
        {
            context.Saga.UserId = context.Message.UserId;
            context.Saga.CreatedOnUtc = DateTime.UtcNow;
        })
        .Retry(r => r.Intervals(2, 2, 2), r => r
            .Activity(x => x.OfType<OrderCreateRequestActivity>())
            .Publish(context => new OrderCreateRequestedEvent(context.Message.OrderId, context.RequestId!.Value, context.ResponseAddress!.ToString()))
            .TransitionTo(OrderCreateRequested)
        )
        .Catch<Exception>(x => x
            .TransitionTo(OrderCreateRequestFailed)
        )
 );

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@phatboyg
Comment options

Answer selected by muratyuceer
Comment options

You must be logged in to vote
2 replies
@phatboyg
Comment options

@muratyuceer
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants