Pattern: Link Lookup Resource

How can message representations refer to other, possibly many and frequently changing, API endpoints and operations without binding the message recipient to the actual addresses of these endpoints?


The final version of this pattern is featured in our book Patterns for API Design: Simplifying Integration with Loosely Coupled Message Exchanges.

Pattern: Link Lookup Resource

a.k.a. Address Data Holder, API Directory, Endpoint Repository, Inventory/Discovery Resource, Service Registry

Context

The message representations in request and response messages of an API operation must satisfy the information needs of the message receivers entirely. To do so, these messages may contain references to other API endpoints. Sometimes, it is not desirable to expose such endpoint references to all clients directly because such direct exposure adds coupling (thus harming location and reference autonomy).

Two reasons to avoid an address coupling between communication participants are: 

  • As an API provider, I want to be able to change the destinations of links freely when evolving API while workload grows and requirements change.
  • As an API client, I do not want to have to change code and configuration (e.g., application startup procedures) when the naming and structuring conventions for links change on the provider side.

Problem

How can message representations refer to other, possibly many and frequently changing, API endpoints and operations without binding the message recipient to the actual addresses of these endpoints?

Forces

When structuring an API that deals with linked resources and data (in the broadest sense of these words), conflicting concerns exist:

  • Coupling between clients and endpoints
  • Dynamic endpoint references
  • Centralization vs. decentralization
  • Message sizes, number of calls, resource use
  • Dealing with broken links
  • Number of endpoints and API complexity

Pattern forces are explained in depth in the book.

Solution

Introduce a special type of Information Holder Resource, a dedicated Link Lookup Resource endpoint that exposes special Retrieval Operation operations that return single instances or collections of Link Elements that represent the current addresses of the referenced API endpoints.

Sketch

A solution sketch for this pattern from pre-book times is:

Figure 1: Link Lookup Resource (Sketch). A Lookup Resource is an API endpoint that merely holds information about other ones.

Example

In the Lakeside Mutual sample application, we can define two operations to find Information Holder Resources that represent customers (notation: Microservice Domain-Specific Language (MDSL), a new style- and technology-independent service contract modeling language Kapferer and Zimmermann (2020)):

API description MAPLinkLookupResource

data type URI P // protocol, domain, path, parameters

endpoint type LinkLookupResourceInterface // sketch 
 exposes 
  operation lookupInformationHolderByLogicalName
    expecting payload  
      <<Identifier_Element>> "name": ID 
    delivering payload
      <<Link_Element>> "endpointAddress": URI 
   
  operation lookupInformationHolderByCriteria
    expecting payload { 
      "filter": P 
    }
    delivering payload {
      <<Link_Element>> "uri": URI* // 0..m cardinality 
    }
      
API provider CustomerLookupResource 
  offers LinkLookupResourceInterface

If multiple results of the same type are returned, the Link Lookup Resource turns into a Collection Resource Allamaraju (2010).

Are you missing implementation hints? Our papers publications provide them (for selected patterns).

Consequences

The resolution of pattern forces and other consequences are discussed in our book.

Known Uses

Instances of Link Lookup Resource can be found in public Web APIs and sample applications:

Terravis Berli, Lübke, and Möckli (2014) internally offers and utilizes a lookup service that returns concrete API endpoints for given banks, notaries, and land registries. All these parties are referred to by a so-called Business Partner Identifier (BPID), which can be sent to the lookup service which then returns all known API endpoints offered by the identified partner.

Terravis also requires all parties to offer a service endpoint that returns a list of all supported APIs with their respective versions as a Version Identifier, as well as the actual endpoint. Terravis will query this service daily and cache the offered API versions and endpoints for use throughout the day.

Web Service Inspection Language (WSIL) support in SOAP-based Web services endpoints and Universal Description, Discovery, and Integration (UDDI) APIs can be seen as obsolete implementations and known uses of Link Lookup Resource concepts.

More Information

Related Patterns

Instances of this pattern can return links to any of the endpoint types/roles, often to Information Holder Resources.

The pattern can be combined with Retrieval Operations (on operation level). For instance, a Retrieval Operation instances may return Id Elements pointing at Information Holder Resources indirectly (that in turn return the data); the Link Lookup Resource turns the Id Element into a Link Elements.

The Collection Resource recipe 2.3 in the RESTful Web Services Cookbook Allamaraju (2010) can be seen as a RESTful HTTP pendant of this pattern, adding add and remove support; Chapter 14 then discusses discovery.

This pattern is an API-specific version/refinement of the more general Lookup pattern described in Kircher and Jain (2004) and Voelter, Kircher, and Zdun (2004). At a more abstract level, the pattern also is a specialization of the Repository pattern described in Evans (2003).

Other Sources

SOA books cover related concepts such as service repositories and registries. In Responsibility-Driven Design (RDD) terms, a Link Lookup Resource acts as a structurer Wirfs-Brock and McKean (2002).

References

Allamaraju, Subbu. 2010. RESTful Web Services Cookbook. O’Reilly.
Berli, Walter, Daniel Lübke, and Werner Möckli. 2014. “Terravis – Large Scale Business Process Integration Between Public and Private Partners.” In Proc. INFORMATIK 2014, 1075–90. Gesellschaft für Informatik e.V.
Erl, Thomas, Benjamin Carlyle, Cesare Pautasso, and Raj Balasubramanian. 2013. SOA with REST - Principles, Patterns and Constraints for Building Enterprise Solutions with REST. Prentice Hall.
Evans, Eric. 2003. Domain-Driven Design: Tacking Complexity in the Heart of Software. Addison-Wesley.
Kapferer, Stefan, and Olaf Zimmermann. 2020. “Domain-Driven Service Design - Context Modeling, Model Refactoring and Contract Generation.” In Proc. 14th Advanced Summer School on Service-Oriented Computing (SummerSOC), 189–208. Springer. https://doi.org/10.1007/978-3-030-64846-6_11.
Kircher, Michael, and Prashant Jain. 2004. Pattern-Oriented Software Architecture, Volume 3: Patterns for Resource Management. Wiley.
Pautasso, Cesare, Olaf Zimmermann, Mike Amundsen, James Lewis, and Nicolai M. Josuttis. 2017. “Microservices in Practice, Part 1: Reality Check and Service Design.” IEEE Software 34 (1): 91–98. https://doi.org/10.1109/MS.2017.24.
Voelter, Markus, Michael Kircher, and Uwe Zdun. 2004. Remoting Patterns - Foundations of Enterprise, Internet, and Realtime Distributed Object Middleware. Wiley.
Webber, Jim, Savas Parastatidis, and Ian Robinson. 2010. REST in Practice: Hypermedia and Systems Architecture. 1st ed. O’Reilly.
Wirfs-Brock, Rebecca, and Alan McKean. 2002. Object Design: Roles, Responsibilities, and Collaborations. Pearson Education.
Zimmermann, Olaf, Mark Tomlinson, and Stefan Peuser. 2003. Perspectives on Web Services: Applying SOAP, WSDL and UDDI to Real-World Projects. Springer.