Selecting endpoints dynamically without using a registry

You can choose which service is used at runtime by looking up service endpoints from a database, or with information from the message itself.

Dynamic routing is enabled by the Use dynamic endpoint property in the callout node that sets the callout to be dynamic. When the dynamic callout is invoked, it checks the /headers/SMOHeader/Target/address element in the message header for a service endpoint address, and routes the message to the address of that endpoint. If no address exists in the target address element, a service will be selected statically, if an import is wired to the associated reference of the callout in the mediation flow component. By default, the Use dynamic endpoint is enabled.

The target address element in the message header can be updated in a number of ways. You can use a Database Lookup primitive to retrieve a service endpoint from a database and place the retrieved URI directly into the target address element of the message. Or, you can use a Message Element Setter or Custom Mediation primitive to process the message and update the target address.

Follow these steps to create a mediation flow that uses a Database Lookup primitive to query a database and set the target endpoint address in the message header. .

  1. Create a mediation flow component, and add a source interface and a target reference that contains the operation that you wish to invoke.
  2. Select the callout node, and click on the details page in the properties view. Ensure that the Use dynamic endpoint check box is selected.
  3. Optional: Promote the Use dynamic endpoint property so that the administrator can change it at runtime. Click the Promoted properties page, and select the promoted check box for the property.
  4. Drop a Database Lookup primitive onto the mediation flow canvas, and enter your query properties, as well as the column that contains the endpoint addresses. Set the Message element property to /headers/SMOHeader/Target/address in order to place the retrieved endpoint address into the dynamic callout target address. For more information, see the properties example at the end of this topic.
  5. Optional: Promote the key path and key column name properties of Database Lookup so that you can change your query at runtime. Click the Promoted properties page, and select the promoted check box for the property.
  6. Optional: You can specify a default endpoint that the runtime uses if it cannot find a dynamic endpoint. You specify a default endpoint by wiring an import to the mediation flow component.
  7. Optional: If there are no endpoints matching the search criteria in the database, the message is propagated to the keyNotFound terminal of the Database Lookup primitive. You can wire the keyNotFound terminal to a mediation primitive for notification, such as a Message Log or Event Emitter.

Example:

The following image shows an example mediation flow using the Database Lookup primitive.Example mediation flow showing dynamic callout with Database Lookup

The following example shows the properties of the Database Lookup primitive: Example of Database Lookup properties

Related concepts
WebSphere Service Registry and Repository (WSRR)
Related tasks
Selecting endpoints dynamically using registry lookup
Related reference
Dynamic endpoint example URIs
Message routing when dynamic endpoint property is set
Database Lookup mediation primitive

Feedback
(C) Copyright IBM Corporation 2005, 2006. All Rights Reserved.