Document transactional session implications
Improve the transaction session guidance to clarify the following:
- It cannot be used as a "store and forward" replacement with local storage and remote broker
- When using outbox the transport must still be available to dispatch the control message
- Sends and publishes can in certain scenarios be affected by additional dispatch latency
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.