Can DDD Application Service call another Application Service?

Asked

Viewed 288 times

2

Not if someone has ever been through this situation, I have application service that performs inventory outputs (Stoqueservice) directly and have an application service that performs sales receipt (Vendasservice). But in the workflow of receiving a sale (Vendasservice) i need to realize stock outputs (Stoqueservice).

I should call the Stoqueservice to perform this function from within the Vendasservice?

Or the client (in my case the view) of the services should call the Vendasservice to make the receipt and then Stoqueservice to make the exit? So the client would have much knowledge of the workflow.

I thought about creating another service that encapsulates this workflow and so the client just needs to call the new service.

Is this a case of communication between Bounded Contexts? In my case I’m not distinguishing between contexts.

UPDATE

In Vaughn Vernon’s book he references a Domain Event Handler that calls another Application Service that modifies a second Application Service.

Maybe this is the best way, as long as I figure out how to create a new transaction instead of creating a nested transaction. Or run handlers after finishing the first transaction as I read in this article http://bartswennenhuis.nl/managing-multiple-transactions-in-one-request-3/

  • 1

    "i have application service that performs inventory outputs" - an application service should not perform any business rule - it at most invokes the rules of business. An application service consuming another application service is strange - it seems to indicate that it is doing too many things. Already a Domain service consume another Domain service is natural and has no problem in it.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.