Composite services
Composite services are services that result from combining two or more services into a new service in a straightforward manner, and provide more value. Composite services avoid the need to implement reoccurring composition logic in clients.
Where to put the composition logic?
There are two options for the location of composition logic:
Service consumer: The client invokes several service operations to accomplish a certain result.
Service: A new service is created that invokes the different service operations and exposes this functionality as a new, single operation.
The following figure shows the difference between these variants using the example of the DocumentService
. On the left-hand side, a DocumentService
is created in which the generateDocument
operation contains the logic to combine several underlying services. Service consumers invoke this new operation of the composite service. In the right-hand side service consumers implement the composition logic.
It pays off...