This sample shows you how to invoke an endpoint dynamically, by retrieving the address from a database at runtime.
A financial services company provides an interactive Web-based stock market service to its customers. The company wants to differentiate itself from its competition by offering tiered levels of service. The company's goal is to offer delayed stock quotes to their standard customers and real-time quotes to their premium customers, that is, customers who pay a subscription.
In the Stock Quote sample, a Lookup primitive retrieves the
customer's subscription level from a database, and a Filter primitive is used
to determine the service to invoke based on the subscription level. The service
is invoked statically, using the address that is specified in the import's
binding, as shown below:
In this sample, a CustomerLookup primitive is also used to retrieve the customer's subscription level, and then another Database Lookup primitive, ServiceAddressLookup, retrieves the service address from a database based on the subscription level. The service is then invoked using the address that is retrieved from the database.
In this scenario, the service address can be changed or replaced at any time in the database without affecting the flow. Subscription levels and their associated endpoints can also be added without changing the mediation flow. The static stock quote is hard coded for two service levels only, and one would have to change the flow in order to accommodate a new service level, or a change in service address.
The picture below illustrates the mediation
flow for this sample.