12/18/2022 0 Comments Masstransit microservices![]() There is an abstract interface in the domain used to issue such messages. Publishing events or sending commands is done fairly well, from a Clean Architecture perspective. MassTransit is also used to place work in background threads for processing. The microservices I have been working with use MassTransit to broker messages between services. But there may be some good that may come from attempting such abstractions regardless. Introducing these concepts now would be a large departure from the rest of the codebase. The code is much more complicated and more challenging to test. But it has taught me a valuable lesson about the side effects of these decisions. More often than not you’ll find HTTP requests and interactions with the persistence logic intermingled with the core business logic. The projects that I have been working on don’t do this particularly well. The implementation is kept out of the Domain layer and that is the important bit here. In fact, in some scenarios, the abstraction looks identical to the ‘standard’ Repository pattern. The abstraction in the Domain layer is an interface definition for the functionality: ![]() The API layer includes all the HTTP functionality one could want, so placing the HTTP implementation details in this layer makes sense as well. ![]() But you amy also choose to place the implementation in the API layer as well. If you are using the HTTP services as persistence, then it makes sense to include this within the application’s Persistence layer. An abstraction layer is defined in the Domain layer and its implementation is defined outside of this layer. The ‘Clean Architecture’ way of utilizing this is no different than how persistence should be tackled. NET project types, not only ASP.NET Core. The factory is configured in the Startup class. The standard mechanism in ASP.NET Core for making HTTP requests is the HttpClient class, created via the IHttpClientFactory. Any mixing of these concepts in the code makes achieving the benefits of a Clean Architecture difficult. Whatever your preference, the important thing to remember is to keep proper independence of each concern. Some teams feel each deserves its own project, while others don’t. NOTE There is no universally-accepted guidance on how to split these into separate projects/assemblies. To implement an HTTP API for callers to make requests to the microservice. To implement logic to persist data to and retrieve data from a data store. To store the core business logic of the application Using ASP.NET Core, the assumption I make for a Clean Architecture is to layer the applications similar to this: Layer/Namespace But the remaining dependencies need to be addressed properly to maintain the proper framework independence in the business logic. ![]() ![]() They are accessed via HTTP requests or publishing messages, via a message broker.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |