zarusz / SlimMessageBus

Lightweight message bus interface for .NET (pub/sub and request-response) with transport plugins for popular message brokers.
Apache License 2.0
467 stars 78 forks source link

[Host.Outbox] Ability to filter UseSqlTransaction and UseOutbox by message type #291

Closed zarusz closed 1 month ago

zarusz commented 1 month ago

What: Adding an option to determine message types filter in the following outbox declarations:

mbb.UseOutbox(messageTypeFilter: t => t.Name.EndsWith("Command"));
mbb.UseSqlTransaction(messageTypeFilter: t => t.Name.EndsWith("Command"));
mbb.UseTransactionScope(messageTypeFilter: t => t.Name.EndsWith("Command"));

The filtering happens at configuration time.

Why: We can have an In-Memory bus for CQRS where only command messages require to be wrapped in a transaction and query messages do not. Without it we would have to declare two memory child buses - for commands and queries.

Optimization: Moreover, the UseSqlTransaction() will be registered for the enabled message types (consumers, or bus) only. Before the interceptor was registered DI wide, and interceptor was checking matching consumers at runtime.

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
89.6% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud