Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use different DbContext for different Outbound messages to use Outbox pattern? #163

Open
RomanOlegovich opened this issue Apr 27, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@RomanOlegovich
Copy link

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
image

@BEagle1984
Copy link
Owner

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).

@RomanOlegovich
Copy link
Author

RomanOlegovich commented Apr 29, 2022

Thank you for answer. Unfortunately, TransactionScope makes impossible to use different databases in different modules.

@BEagle1984
Copy link
Owner

Why?

@RomanOlegovich
Copy link
Author

As you say "not all drivers support the ambient transactions"

@RomanOlegovich
Copy link
Author

Does silverback support TransactionScope?

@BEagle1984 BEagle1984 added the enhancement New feature or request label Apr 29, 2022
@BEagle1984
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants