-
Notifications
You must be signed in to change notification settings - Fork 1
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
OutboxTableConfig #3
Comments
Hey John... Thanks again for the Coffee! I truly appreciate it! Great question, it's quite easy . . . the Though the default public class CustomSchemaNameOutboxTableConfig : OutboxTableConfig, ISqlTransactionalOutboxTableConfig
{
public CustomSchemaNameOutboxTableConfig(string customOutboxSchemaName)
{
TransactionalOutboxSchemaName = customOutboxSchemaName;
}
public new string TransactionalOutboxSchemaName { get; }
} Then you can specify it as an optional dependency when you construct the var customOutboxTableConfig = new CustomSchemaOutboxTableConfig("sqloutbox");
var sqlTransaction = (SqlTransaction)await sqlConnection.BeginTransactionAsync().ConfigureAwait(false);
var sqlOutboxRepository = new DefaultSqlServerOutboxRepository<string>(
sqlTransaction,
outboxTableConfig: customOutboxTableConfig //<== Inject your Custom Configuration!
);
/// . . . Carry on with the Outbox processing . . . |
I also just realized that the properties of But that doesn't affect the above solution which should work just fine since the interface is key and there is no other polymorphic access to the base class. To validate and illustrate, I added a Unit Test which illustrates the above example in the project: Line 13 in b11d6e4
|
Thank you @cajuncoding (Brandon). I am implementing a background task within a microservice that pushes domain events to the service bus from the It appears that I will have to create my own
Once again I want to thank you for providing this solution. I do have one other question that I am concerned about, which I am hoping you can help me to better understand if I will have an issue or not. As mentioned, each microservice will have a background processor task, who's primary role is to process domain events from the `TransactionalOutBoxQueue table and where, each microservice will own it's own TransactionalOutBoxQueue table. I need to ensure that if there are multiple instances of a microservice and as such, competing consumers to those events, that the background task processor(s) will read and process each block of events to the Azure service bus in the order (and at most one) that they were added to the event table. It seems like that this will work using your library, but I just wanted to be absolutely certain it will. Thanks for your support! |
I am really confused as to how I would integrate with your library. I fully understand that I need to create a custom outbox config however what class am I placing the code below into?
... such that I can easily call through the Can you please help me with the classes I need to implement. |
Regarding customizing the OutboxTableConfig and using the Sql Connection/Transaction custom extensions.... yeah I see your point now. The custom extensions are very helpful and handle a bunch of logistics for transaction, rollback, etc. And ideally you wouldn't have to copy/paste that 🤔 Ok, I've got an idea or two.... but let me think on it and I'll take a closer look tomorrow. Ideally I think it'd be good offer an easy to use way to change the |
Regarding your more involved question above:
Yes I'm pretty sure that the library will accomplish what you are looking to do... but just to make sure I understand the nuances of the question here are some thoughts off the top of my head...
|
Hi and thank you @cajuncoding for your detailed response, most awesome! From review of your code and stepping through of your console sample I was thinking it worked as described above, for which I am super happy to learn that it works that way. To provide a bit more perspective as to who we are and what we are doing, my company is NextWare Group and we are a very small tech-start-up. We have developed an in-house Domain modeling tool that is a VS Code extension that we use to capture Business Domains for some up-coming product ideas we are working on. We are following the key principals of Domain Driven Design, in which we utilize Event Storming to capture any business domain and then use our Domain Tooling to graphically capture each related Bounded Context per the domain, including each related Aggregate schema(s), API Command(s) and Domain Event(s) in a drag-n-drop diagram editor as seen below. We have a separate CLI tool that utilizes MS Roslyn to code-generate each domain model into the actual microservices. A domain model contains 1 or more Bounded context(s) which code-generates to a ASP.Net Web API microservice and each Bounded Context has 1 or more Domain Aggregates. We are deploying to Azure Container Apps. The domain model screen shot below is from our ERP platform we are currently working on. Here, I am showing just two aggregates (JournalConfiguration and JournalBatch) within the GeneralLedgerServices microservice. On the left side in the VS Code Explorer you will see the code that is generated by the CLI tooling from this model. Currently we have 20 domain models in our ERP domain, consisting of 40+ microservices and 500+ aggregates. Below is a test model and some code-generated ChangeFeedBackGroundService.cs task, we will use to process MS SQL domain events using your SQLTransactionalOutbox pattern. Our tooling code-generates either to MS SQL (EF Core), or MS CosmosDB. With CosmosDB we utilize the built-in change-feed mechanism to publish the domain events to the service bus as well as project to MongoDB, via a code-generated background task processor. We generate REST, gRPC and GraphQL API integrations for each microservice (configurable). We have an integrated Business Rules Engine (Code Effects), as such we rarely need to write any code, although we can if we need some special business logic not able to be captured via Business Rules. I would love to hook up and provide you a demo of this if you have time, and then we can chat more about what we are doing with your library. Please let me know if you have time to join a Zoom call, I can be reached via LinkedIn. Cheers |
John, That's alot of details to process 🤯😁 I've just merged in the PR to provide full configuration at initialization... added some details to the README for how to use it during app startup.... it's very straightforward bootstrapping/initialization feature now added. All unit tests are passing, so it's pushed to an updated Nuget Package v1.0.1 now 👍 For your case -- if all you need to change is the Schema name -- then you'll just add this to your Startup (application root): //This is the global SqlTransactionalOutbox initializer that allows configuring custom settings to be used...
//NOTE: Not all values need to be specified, any values that are not specified (e.g. or are set to null)
// will retain the default values.
SqlTransactionalOutboxInitializer.Configure(config =>
{
config.WithOutboxTableConfig(new OutboxTableConfig(
transactionalOutboxSchemaName: "YourCustomSchemaName"
));
}); |
Hi @cajuncoding (Brandon), that worked, however I am had to make one change, which I am certain I shouldn't have to do. I changed the following line in the base initializers within the DefaultSqlServerOutboxRepository....
Is that the correct way to bring the new configuration in, or is there a proper way that I need to follow? |
Awesome! I will try now. |
Perfection! Many, many thanks! Here is a quick test model that a created to test this. The UpdateAgg1Name command takes in a string and applies that to the name property of the the Aggregate. GraphQL of that aggregate prior to the change... Make a change... This will generate the Agg1NameHasChanged domain event which is pushed into the Which arrives nicely as a topic in ASB ... And the changes is applied to the aggregate... |
Thank you so very much (@cajuncoding) for both this wonderful community contribution as well as helping me out. We will continue testing against real domain models and will let you know if we find any issues. Cheers |
How do we alter the schema name in OutboxTableConfig?
The text was updated successfully, but these errors were encountered: