Open RomanOlegovich opened 2 years ago
It's currently not possible.
The configuration will become more flexible in Silverback 4 and allow for this scenario (sneak-peak: https://github.com/BEagle1984/silverback/blob/release/4.0.0/tests/Silverback.Integration.Tests.E2E/Kafka/OutboxFixture.cs#L56) but we are still a bit far from the delivery date (which I cannot even estimate at the moment).
In your case, it would probably make sense to have a DbContext dedicated to the Silverback tables and use that across all your modules/features. Then you can use an ambient transaction (using the TransactionScope
) to ensure the transactionality between the contexts (not all drivers support the ambient transactions, but it's not an issue since you seem to use SqlServer).
Thank you for answer. Unfortunately, TransactionScope makes impossible to use different databases in different modules.
Why?
As you say "not all drivers support the ambient transactions"
Does silverback support TransactionScope?
The transaction is only a database thing, Silverback supports what the underlying database driver library supports. If you use MSSQL, it surely works. If you use something different just have a look at the driver's documentation to know if it's supported.
The application is designed as a modular monolith. Where each module communicates with another via kafka. Therefore, there are multiple DbContexts in one project. I want to use the Outbox pattern, but the problem is that can only specify 1 DbContext