During(Creating,
When(RecordCreated)
.ThenAsync(async context =>
{
if (context.Data.TimeStamp > context.Instance.Updated)
context.Instance.Updated = context.Data.TimeStamp;
await context.CreateConsumeContext().Publish<Processing1>(new
{
CorrelationId = context.Instance.CorrelationId,
Timestamp = DateTimeOffset.UtcNow,
Index = context.Data.Index
});
await context.CreateConsumeContext().Publish<Processing2>(new
{
CorrelationId = context.Instance.CorrelationId,
Timestamp = DateTimeOffset.UtcNow,
Index = context.Data.Index
});
await context.CreateConsumeContext().Publish<Processing3>(new
{
CorrelationId = context.Instance.CorrelationId,
Timestamp = DateTimeOffset.UtcNow,
Index = context.Data.Index
});
})
.TransitionTo(Processing)
);
public bool Processing1Finished { get; set; }
public bool Processing2Finished { get; set; }
public bool Processing3Finished { get; set; }
When(Processing1Finished)
.Then(context => {
if (context.Data.Timestamp > context.Instance.Updated)
context.Instance.Updated = context.Data.Timestamp;
context.Instance.Processing1Finished = true;
}),
When(Processing1Failed)
.Then(context => {
if (context.Data.Timestamp > context.Instance.Updated)
context.Instance.Updated = context.Data.Timestamp;
context.Instance.Processing1Finished = true;
}),
Why don't you use a composite event?
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/08381407-e7de-4b36-9845-758d489c338c%40googlegroups.com.
Alexey is right, think composite and have a separate event for each parallel step, once all three are done, bingo.Also, in your first code snipped, using Then() to update the Updated property, and after that, end the Then() closure and use .Publish() instead of calling CreateConsumeContext() so many times. Makes the code easier to understand and read, not to mention, just looks nicer.
On Mon, Oct 9, 2017 at 1:36 PM, Alexey Zimarev <azim...@gmail.com> wrote:
Why don't you use a composite event?
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/1d7bdf4e-49a0-4ab6-aef7-6daf5b960db4%40googlegroups.com.