docs.particular.net icon indicating copy to clipboard operation
docs.particular.net copied to clipboard

Document transactional session implications

Open ramonsmits opened this issue 3 years ago • 1 comments

Improve the transaction session guidance to clarify the following:

  1. It cannot be used as a "store and forward" replacement with local storage and remote broker
  2. When using outbox the transport must still be available to dispatch the control message
  3. Sends and publishes can in certain scenarios be affected by additional dispatch latency

ramonsmits avatar Dec 14 '22 12:12 ramonsmits

I would add that further details should be shared in the documentation (or addressed by the component) becuase the transactional session has some unique implications on dependency injection ordering.

A user reported to me that that they had a Controller which depended on both DbContext and ITransactionalSession, which were injected into the controller action method, but becuase the DbContext parameter was ordered first, like this:

[HttpPost]
public async Task<IActionResult> ActionName(MyModel model,
    [FromServices] MyDbContext dbContext,
    [FromServices] ITransactionalSession messageSession)
{
    //..
}

In the user's words:

…the code to connect the db connection & transaction up to EF didn’t have a transactional session yet, so they ended up disconnected. Once I reversed the argument order, things started working as expected.

Perhaps this wouldn't happen if the dependencies were constructor-injected, but even so this is frighteningly easy to get wrong.

DavidBoike avatar Jun 05 '23 16:06 DavidBoike