Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using IntegrationTests;
using JasperFx.Core;
using Marten;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
Expand Down Expand Up @@ -39,7 +40,10 @@ public async Task should_work_but_doesnt()

var id = Guid.NewGuid();

await host.InvokeMessageAndWaitAsync(new SomeCommand(id));
await host.TrackActivity()
.Timeout(30.Seconds())
.WaitForMessageToBeReceivedAt<SomeTimeout>(host)
.InvokeMessageAndWaitAsync(new SomeCommand(id));

using var session = host.Services.GetRequiredService<IDocumentStore>().LightweightSession();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using JasperFx.CodeGeneration.Frames;
using JasperFx.CodeGeneration.Model;
using JasperFx.Core.Reflection;
using Microsoft.EntityFrameworkCore.Storage;
using Wolverine.EntityFrameworkCore.Internals;
using Wolverine.Persistence;
using Wolverine.Runtime;
Expand All @@ -24,12 +23,9 @@ public EnrollDbContextInTransaction(Type dbContextType, IdempotencyStyle idempot
_dbContextType = dbContextType;
_idempotencyStyle = idempotencyStyle;

Transaction = new Variable(typeof(IDbContextTransaction), $"tx_{_dbContextType.NameInCode().Sanitize()}", this);
_envelopeTransaction = new Variable(typeof(EfCoreEnvelopeTransaction), this);
}

public Variable Transaction { get; }

public override void GenerateCode(GeneratedMethod method, ISourceWriter writer)
{
writer.WriteLine("");
Expand All @@ -39,9 +35,11 @@ public override void GenerateCode(GeneratedMethod method, ISourceWriter writer)
writer.Write(
$"await {_context.Usage}.{nameof(MessageContext.EnlistInOutboxAsync)}({_envelopeTransaction.Usage}).ConfigureAwait(false);");


writer.WriteComment("Start the actual database transaction");
writer.Write($"using var {Transaction.Usage} = await {_dbContext.Usage}.Database.BeginTransactionAsync({_cancellation.Usage}).ConfigureAwait(false);");

writer.WriteComment("Start the actual database transaction if one does not already exist");
writer.Write($"BLOCK:if ({_dbContext.Usage}.Database.CurrentTransaction == null)");
writer.Write($"await {_dbContext.Usage}.Database.BeginTransactionAsync({_cancellation.Usage}).ConfigureAwait(false);");
writer.FinishBlock();
writer.Write("BLOCK:try");

// EF Core can only do eager idempotent checks
Expand Down
Loading