0

Service composition is a fundamental part of SOA. All of the capabilities offered by a service inventory are expected to utilize other services within that inventory, where necessary, in order to build the task that they are accomplishing from smaller component parts. This is all from an architectural level, though: how does this composition happen at the implementation level?

Consider this situation. I have a "task service" which involves posting a /process-request resource that will manage additional resources involved in asynchronously processing a large file to generate the "real" resource. Let's call the eventual "real" resource a PartsInventory. So, you provide a URL and a name for the PartsInventory to the /process-request service, which then creates a PartsInventory "placeholder" and kicks off the asynchronous ETL involved in converting the massive csv file at your URL into a real PartsInventory. If this asynchronous job fails, it will remove the placeholder and queries to the /process-request service will reflect the failure. If it succeeds, it will remove the placeholder status and queries to the /process-request service will instead redirect you to the PartsInventory resource.

Now, how does the implementation of the interaction between /process-request and the PartsInventory look, from a code standpoint? Am I POSTing requests to a published /parts-inventory service, or am I calling ORM objects to create the placeholder? If the former, I am abiding by the published contract and am behaving as a consumer of my own services, which seems to fit the composability principle--but it feels really awkward to interact this way from within the same codebase. On the other hand, the latter presumes that the /process-request handler is going to know about how to create a PartsInventory placeholder on its own, which feels awkward in itself. The third option would be to create a specialized static factory method on the PartsInventory object, called something along the lines of PartsInventory.create_placeholder(), so that the /process-request code is at least ignorant of the constructor dependencies of a PartsInventory object. This does still separate creation into two locations, though.

Have you encountered this? Is there a canonical "right answer" to this question?

1 Answer 1

0

You should differentiate between service endpoints (in your case urls exposed by the various services) and services. Services are basically components with, what should be, well defined boundaries that expose one or more endpoints where they deliver contracts (made of messages).

Calls made within the service don't have to go through service interface calls that cross service boundaries do have to go through service interface.

The question in your case is are process-request and PartsInventory different aspects of the same service or not. I can't understand from the details in your service if they are or aren't but if they really make sense as different services you should go through the service interface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.