-
-
Notifications
You must be signed in to change notification settings - Fork 295
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Describe the bug
Returning a saga instance that was MarkCompleted from a static Start method does not cause persistence to skip.
To Reproduce
namespace Testing;
public record StaticMessage;
public class StartIsStaticMethod : Saga
{
public string? Id { get; set; }
public static StartIsStaticMethod Start(StaticMessage message)
{
var saga = new StartIsStaticMethod();
saga.MarkCompleted();
return saga;
}
}This generates:
// <auto-generated/>
#pragma warning disable
using Microsoft.Extensions.Logging;
namespace Internal.Generated.WolverineHandlers
{
// START: StaticMessageHandler426984011
[global::System.CodeDom.Compiler.GeneratedCode("JasperFx", "1.0.0")]
public sealed class StaticMessageHandler426984011 : Wolverine.Runtime.Handlers.MessageHandler
{
public override async System.Threading.Tasks.Task HandleAsync(Wolverine.Runtime.MessageContext context, System.Threading.CancellationToken cancellation)
{
// The actual message body
var staticMessage = (Testing.StaticMessage)context.Envelope.Message;
await using var sagaStorage = await Wolverine.Persistence.Sagas.SagaSupport<string, Testing.StartIsStaticMethod>.EnrollAndFetchSagaStorage(context);
var sagaStorage_Slim = sagaStorage;
// The actual message execution
var outgoing1 = Testing.StartIsStaticMethod.Start(staticMessage);
// This should check for "outgoing".IsCompleted.
await sagaStorage_Slim.InsertAsync(outgoing1, cancellation);
await sagaStorage.SaveChangesAsync(cancellation);
}
}
}Expected behavior
Same behavior as with a non-static Start method, where IsCompleted is checked before calling the persistence.
namespace Testing;
public record InstanceMessage;
public class StartIsInstanceMethod : Saga
{
public string? Id { get; set; }
public void Start(InstanceMessage message)
{
MarkCompleted();
}
}generates:
await using var sagaStorage = await Wolverine.Persistence.Sagas.SagaSupport<string, Testing.StartIsInstanceMethod>.EnrollAndFetchSagaStorage(context);
var sagaStorage_Slim = sagaStorage;
var startIsInstanceMethod = new Testing.StartIsInstanceMethod();
// The actual message execution
startIsInstanceMethod.Start(instanceMessage);
if (!startIsInstanceMethod.IsCompleted())
{
await sagaStorage_Slim.InsertAsync(startIsInstanceMethod, cancellation);
}
// No additional Unit of Work necessary
await sagaStorage.SaveChangesAsync(cancellation);Wolverine 5.12.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working