WebSphere

Patterns

The ESB architectural pattern has a number of common instantiations that can be represented as design patterns. Some design patterns can help increase the flexibility of your systems, and the reuse of your service.

This topic describes two of the common patterns used for routing.

Pattern one: using one service result to invoke another service

Invoke a service in the middle of a mediation flow, and use the result to make a routing decision.

You can use the Service Invoke mediation primitive to call an external service in the middle of a mediation flow. You can determine the characteristics of the call to the service by customizing the properties of the mediation primitive. (If you need additional mediation primitive flexibility, you can use the Custom Mediation primitive, rather than the Service Invoke mediation primitive.)

You can use the result of invoking the service to do further processing, and make a routing decision. You could also use the result of invoking the service to augment the original request message.

Generally, you need to save the current message before making a service call that is in the middle of a mediation flow. For example, you could use the XSLT mediation primitive to save the current message in the transient context. You could then make the service call, and afterwards use another XSLT mediation primitive to make use of the service response and the original message, which is saved in the transient context.

Pattern two: using registries and databases to store service endpoints

Invoke a service by querying a registry or database for the service endpoint.

You can use the following mediation primitives to directly call a registry or a database:
  • The Endpoint Lookup mediation primitive. You can determine the characteristics of the call to the registry by customizing the properties of the mediation primitive.
  • The Database Lookup mediation primitive. You can determine the characteristics of the call to the database by customizing the properties of the mediation primitive.
If you need additional mediation primitive flexibility, you can use the Custom Mediation primitive.
You can select a service endpoint from an external source, based on a condition or property in your flow. At development time:
  • You need to know the port type, or interface, of the service you are invoking.
  • You do not need to know the address of the service you are invoking (you get the address at run time from a registry or a database).

Choosing which service endpoint to use at run time, rather than integration time, enables services to be more loosely coupled, and businesses to react faster to change. New services can be added without touching the modules that have been deployed to the run time.

You can use the IBM WebSphere Service Registry and Repository (WSRR) to store service endpoint information, and use the Endpoint Lookup mediation primitive to query the registry for a service endpoint, or a set of service endpoints. If you retrieve a set of endpoints, you can use another mediation primitive to select the one you want to use. Alternatively, you can exploit additional endpoints as alternative targets, to be used if the invocation of the first service fails for some reason.
Figure 1. Dynamic routing using the Endpoint Lookup mediation primitive
Endpoint Lookup mediation primitive, with Match Policy of All, wired to XSLT mediation primitive

Alternatively, you can use a database to store service endpoint information, and retrieve the service endpoint information using the Database Lookup mediation primitive.

To enable dynamic routing, with or without a registry, you must ensure that the following conditions are satisfied at integration time:
  • The mediation flow stores the dynamic endpoint address at the following location in the message:/headers/SMOHeader/Target/address.

    The Endpoint Lookup mediation primitive can automatically copy an endpoint to the correct part of the message (SMO). However, you can use other mediation primitives to copy the dynamic endpoint to the correct location.

  • The Use dynamic endpoint property is set. The Use dynamic endpoint property is set, by default.

concept Concept topic

Terms of use | Feedback


Timestamp icon Last updated: 20 June 2010 00:38:40 BST (DRAFT)


http://publib.boulder.ibm.com/infocenter/dmndhelp/v6r2mx/topic//com.ibm.websphere.wbpm.scenarios.esb1.620.doc/concepts/cwesb_flexibility_patterns.html
Copyright IBM Corporation 2005, 2010. All Rights Reserved.
This information center is powered by Eclipse technology (http://www.eclipse.org).
iDoc on