SOA Pattern of the Week (#5): Service Decomposition
Join the DZone community and get the full member experience.Join For Free
a service inventory is a living body of services that individually will need the freedom to evolve independently over time. what we learned when documenting the soa design pattern catalog is that there are patterns that emerged not only at design-time but also during this post-implementation evolutionary stage in a service’s lifecycle.
there is one common scenario that repeatedly surfaced in many projects:
- when we model and design services during early stages of soa adoption we are constrained by current infrastructure and technology. these constraints require that we limit the size of service compositions and the extent of cross-service message exchanges. as a result, each service encompasses more logic and is coarser grained.
- our infrastructure improves over time (because of new platform upgrades or new funding for better hardware, etc.). our existing service compositions are comprised of coarse-grained services that were delivered within the parameters of the older environment. however, we now realize that services could be more fine grained (and could perform and be composed more effectively) because the infrastructure can support larger service compositions.
it is in response to this situation that the service decomposition pattern provides a technique for splitting up a service after its initial deployment into two or more fine-grained services.
of course, such an approach will raise a few eyebrows from those involved in version control and change management. how can we break apart a service with an established contract without impacting all of the consumer programs that have been using the service and have formed very real runtime dependencies on how it currently exists?
to address these issues, the service decomposition pattern needs the help of several other soa design patterns:
- proxy capability – when logic is moved from one service to another, this pattern can be used to preserve the original capability that is expressed as part of the original service’s contract.
- service façade – in support of enabling proxy capability , this multi-purpose pattern can be used to establish (within the original service logic) a façade layer of processing that acts as a liaison between the original service and the new service. the façade component may actually invoke the corresponding capability on the newly created service, thereby acting as its service consumer on behalf of the consumer of the original service.
- when applying these two patterns together with service decomposition , the façade logic can also be designed to compensate for a change in behavior that is likely to occur as a result of physically moving a segment of the original service logic into a new location.
an important requirement for the decomposition of a service to be successful is that the resulting, more fine-grained services have distinct functional contexts. when modeling and designing these new services, all applicable service-orientation principles and patterns must be considered as with any other new service. other fundamental patterns, such as service normalization, also need to be applied to ensure that the new services properly line up with the others in the existing service inventory.
one common problem with post-implementation service decomposition, however, is that a given set of capabilities may not correspond cleanly to the functional contexts of the new services. what this means is that a new service may only require a portion of what the original service capability represents.
there are several ways of dealing with this, including a hybrid application of the proxy capability pattern where the original service retains some of its logic but then still calls a new service for the portion that now belongs elsewhere. however, there is yet another pattern we can take into account early on during the initial modeling stages of the original service in anticipation of future decomposition requirements. this pattern is called decomposed capability and it essentially asks us to think ahead as to how a given coarse-grained service context can be split into multiple finer-grained contexts and to then align the initial service capabilities correspondingly.
the soa pattern of the week series is comprised of original content and insights provided to you courtesy of the authors and contributors of the soapatterns.org community site and the book “soa design patterns” (erl et al., isbn: 0136135161, prentice hall, 2009), the latest title in the prentice hall service-oriented computing series from thomas erl ( www.soabooks.com ).
Published at DZone with permission of Herbjörn Wilhelmsen. See the original article here.
Opinions expressed by DZone contributors are their own.