BrighterCommand / BrighterCommand/Brighter
[Feature] Does Outbox supports multiple connections?
- Dominant language
- C#
- Stars
- 2.5k
- Forks
- 296
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
Hello,
I'm trying to use the Outbox implementation of Brighter, but it is not clear to use the Outbox when we have multiple SQL connections.
eg.
```csharp
[HttpGet]
[Route("greeting")]
public async Task TestPubCtx1Async(CancellationToken cancellationToken)
{
using (var trx1 = _greetingsCtx.Database.BeginTransaction())
{
var entity = new GreetingEntity() { GreetingText = "asdasd1" };
_greetingsCtx.Greetings.Add(entity);
_greetingsCtx.SaveChanges();
var integrEvent = new GreetingChangedEvent("Hello from the web1");
await _outbox.DepositPostAsync(integrEvent);
trx1.Commit();
}
return new HttpResponseMessage(System.Net.HttpStatusCode.NoContent);
}
[HttpGet]
[Route("another")]
public async Task TestCtx2Async(CancellationToken cancellationToken)
{
using (var trx2 = _anotherCtx.Database.BeginTransaction())
{
var entity = new TestEntity() { Text = "asdasd2" };
_anotherCtx.SomeEntities.Add(entity);
_anotherCtx.SaveChanges();
var integrEvent = new TestChangedEvent("Hello from the web2");
await _outbox.DepositPostAsync(integrEvent);
trx2.Commit();
}
return new HttpResponseMessage(System.Net.HttpStatusCode.NoContent);
}
```
In the IOC I'm registering the ConnectionProvider using
`.UseMsSqlTransactionConnectionProvider()`
Which will point to only 1 of the 2 possible Contexts.
Ideally, there exists this overload, which would allow me to explicitly provide the transaction, but, for some reason, it is marked as "private"
https://github.com/BrighterCommand/Brighter/blob/7ad1a911422cc71a8ad5a222759da92abc5c5ef6/src/Paramore.Brighter/CommandProcessor.cs#L455
Would you accept a pull-request to make it available as Public, so that I use the Outbox on multiple connections?
Or there exists other way to archive the same result?
Contributor guide
Assessment
This issue has not been assessed yet.