Particular / NServiceBus.TransactionalSession

Transactional message session implementation for NServiceBus
Other
3 stars 1 forks source link

Encapsulate opening and committing the session in an ASP.NET Core middleware #99

Open danielmarbach opened 2 years ago

danielmarbach commented 2 years ago

We decided for now against shipping with a predefined package for the ASP.NET Core middleware because there might be tricky scenarios with how you would want to configure persistence specific OpenOptions. Yet, it might be possible to come up with a clever design to simplify the boilerplate code of

app.UseMiddleware<MessageSessionMiddleware>();
public async Task InvokeAsync(HttpContext httpContext, ITransactionalSession session)
{
    await session.Open(new MyPersistenceSpecificOpenSessionOptions(somePersistenceSpecificConfiguration));

    await next(httpContext);

    await session.Commit();
}
danielmarbach commented 1 year ago

We have recently updated the sample to use a result filter instead of a middleware

That approach turned out to be way more flexible