Open Closed

Calling of Application Services of another modules #1317


User avatar
0
Denis created

Hi

I have issue with modular architecture. My solution consist of multiple modules which calledl as A, B, C All modules are included in monolith application. All of them share same data base.

The problem occurs when endpoint (Application service method) in module A calls Application Service methods in module B Endpoint in module A needs to create couple aggregates in module B, for that it calls

B_app_service_1.CreateB1(data) B_app_service_2.CreateB2(data)

That happens that both methods track same entity. In other words one entity is tracked twice in one UoW and EF core can not perform changes in db If my modules would running as microservices, that would not happen because calls above would be isolated.

My question is how to avoid this situtaion in monotlith deployment? As I know I can force saving changes on endpoint of module A, but that is bad workaround on my opinion. Also I know that UoW is ambient and wrapping of module B application services calls will not help (that is still workaround)

Thanks

  • ABP Framework version: v4.3
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): Separate
  • Exception message and stack trace:
  • Steps to reproduce the issue:

6 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    It looks like your module A depends on module B, Maybe you can consider using event publishing instead of coupling the two modules

  • User Avatar
    0
    Denis created

    Hi liangshiwei,

    Module A uses module B. And events will not help because they will be running in same UoW. Please help me to resolve question in topic

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I don't actually understand your project structure, can you share some code? thanks.

  • User Avatar
    0
    Denis created

    Hi liangshiwei,

    It does not make sense to share code because we are talking about architecture. And I can not share code btw. I explained anough in topic, on my opinion.

    There are 2 modules in monolith app. Module A makes several endpoint calls of module B. It is obvious that this calls share one UoW by default. There can be problems with that because every endpoint in B does take in account it will be called in same UoW with another endpoint

    So question is how to make calling of endpoints of module B isolated, like module be is running in own microservice.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I think you can manually create a new uow: https://docs.abp.io/en/abp/latest/Unit-Of-Work#begin-a-new-unit-of-work

  • User Avatar
    0
    Denis created

    Yes, I did that. I disbaled UoW via attribute and created UoW for each call of endpoints of other module

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09