I recently was asked a question on the difference between entity service and a task service and how they differ from the service consumer and the provider perspective. Here is my definition of a task service:
"A task service encapsulates a business process that creates and updates entities within multiple systems". From the provider perspective, a task service manipulates several business entities spanning multiple systems with varying responsibilities. If we look at the order processing scenario shown in Figure 1, the activities gets mapped to different systems; often outside the
Figure 1: order shipping business process
sphere of influence of the e-commerce system that might be hosting an order acceptance service. A task service like Order Service when implemented can trigger a process that spans multiple implementation systems shown in Figure 2.
Figure 2: order service system associations
From the provider perspective a task service like OrderService touches e-commerce system (Order Manager, Product CatalogManager), fulfillment system and inventory management systems in the process of accepting, packaging and shipping the order. In Figure 2, the service consumer, through task service reads and writes entities in multiple systems. Figure 3 shows a sample definition of OrderService:
Figure 3: typical operations define in an order service
An entity service has far narrower scope than a task service. Following is the definition of an entity service which I frequently use:
"An entity service manages the life time of an entity and its relationships within the boundary of a given functional domain". Figure 4 shows Order Entity Service scoped within the e-commerce system. Order Entity Service responsibilities (within the
Figure 4: order entity service scoped at an e-commerce system
e-commerce system) include the following: create, read single and read list, update, delete and a possible archival. During the process of executing the above operations, the entity service will manage the relationships with the other business entities like product, product catalog and customer.
Figure 5: typical operations in an order entity service
Task service being course-grained in nature, is a good candidate for publishing to customers as well as other internal system. On the other hand, entity services are fine-grained in nature and generally are consumed within a particular system they are coupled to. Figure 4 shows a task service consuming two entity services from the same system. Master data management is an exception where entity services can provide the integration glue between the e-commerce system and the product information management systems. Also, certain entity reader operations (e.g. GetStatus, GetOrdersByCustomer) may be exposed to customers and other internal reporting systems. Careful governance practices have to be followed when entity services are published to outside world as this process sacrifices service autonomy.