Starts in:
2 DAYS
12 HRS
49 MIN
48 SEC
Starts in:
2 D
12 H
49 M
48 S
Open Closed

Distributed Events in monolith #1347


User avatar
0
Denis created

Hi

I have several modules and one of them (A) sends distirbuted event. Another module (B) listening for this event. When modules are deployed in monolith I get endpojnt in module A, which sends the event, finished only after when distributed event processed by module B, because in monolith DIstributed Event Bus works as Local Event bus. I would like to know what option ABP framework can suggest to make distirbuted events processed asynchronously?

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

9 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    maybe you can use https://docs.abp.io/en/abp/latest/Background-Jobs to process the message in the consumer method, then it'll be async

  • User Avatar
    0
    Denis created

    Hi Alper,

    I already resolved the issue by adding RabbitMQ. Now, all events are sent to broker and them return back application. But now I have issue with authorization. Event handler needs to call application sevices, which are protected by authorization.

    How I can do authorization with JWT token which passed to event data?

  • User Avatar
    0
    alper created
    Support Team Director

    why do you need authorization? extract the running code part from AppService and move it to a DomainService. then call the domain service method in your handler. And also use it in your AppService as well.

  • User Avatar
    0
    Denis created

    why do you need authorization? extract the running code part from AppService and move it to a DomainService. then call the domain service method in your handler. And also use it in your AppService as well.

    I need authorization because domain make calls to endpoints of another module. I can not move logic of endpoint in module B to domain of module A, which calls endpoint.

    For instance, domain may call GET User endpoint in Identity module to get Name of user and use it in own purporse

  • User Avatar
    0
    Denis created

    There is also one more example with background jobs. For example I need periodical background job which creates stats about users created passed period. Background Job needs to make endpoint call to Idenity module, but it will not able to do that due it is not authorized

    So question is how to make authorization prodecure in same way as that done in middleware when endpointcalled?

  • User Avatar
    0
    alper created
    Support Team Director

    If there was a authorization, will you use a real user account to authorize? it sounds odd. you need to make a new manager service (domain service) to operate your background job without any authorization requirement. otherwise you break best practises.

  • User Avatar
    0
    Denis created

    Please read carefully what I wrote above. My background job in module A needs to get some data from module B. For example - user amount. How can I move Identity module GetUserCount endpoint logic into domain service of module where background job is implemented?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi @Denis

    I think we can discuss in https://support.abp.io/QA/Questions/1364#answer-b530cbdc-4e38-26cb-4120-39fcae2885e8

  • User Avatar
    0
    Denis created

    Ok. I will close this question

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