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.
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.
Invoke a service by querying a registry or database for the service endpoint.
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.
Alternatively, you can use a database to store service endpoint information, and retrieve the service endpoint information using the Database Lookup mediation primitive.
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.