Approaches to assembling a mediation module

You can assemble a mediation module in a number of different ways; you can begin by using the interfaces of existing services, and then create the implementation. Or you can begin with an implemented mediation flow, and end with an assembled mediation module.

Mediation services allow quick integration of existing services, and operate independently of the services they are connected to. A popular approach to building a mediation service is to discover existing services, and connect to their interfaces by adding imports and exports in a mediation module and wiring them to a mediation flow component. The mediation flow is then implemented. Later, you can easily add actions to the mediation flow, or change service providers

Or, you may have an existing mediation service, and want to add function to it, or change service providers. In this case, you would make changes to an existing mediation module or an implementation, or both.

Another approach is to begin with an implemented mediation flow component that knows the interfaces of their service requester (source) and service provider (target). Now, you want to assemble the services to resolve the references and handle the calls from one service to the other.

Stock Quote example

To illustrate the concepts covered in this topic, we will use an example of a simple mediation service that provides stock quotes. A client application provides a query containing a stock symbol and customer ID to the mediation service, which processes the query. The customer's subscription level is determined, and depending on the level of subscription, the query is routed to the appropriate service provider.

We are using a mediation service because we want to use different interfaces from two external service providers, and expose a single interface to the client application. We also need to build the service quickly, with the ability to change on demand, and without going through a top-down modeling of a business process.

Later, we will modify the mediation service by adding logic to convert the returned quote to the currency that is preferred by the customer.

The following picture shows the complete mediation service:
Picture showing the required application

To build the mediation service, we begin by using the first approach that we described; discovering the service provider interfaces, and assembling the components in a mediation module. Finally, we implement the mediation flow.

To add the currency conversion function, we changed the existing StockQuote mediation module and mediation flow implementation.

The topics that follow describe both approaches. Detailed step-by-step instructions on how to use tools are available from the related information at the end of this topic.

Building the Stock Quote mediation service

We will use a single mediation module that will contain the imports, exports and mediation flow component for our mediation service.
  • First we import WSDL interfaces from the standard and premium service providers, and then create an interface called StockQuoteService to provide the client access to the mediation flow component.
  • We then create a mediation module called StockQuote and open its module assembly in the assembly editor.
  • In the module assembly, we create imports for the service providers interfaces and an export for the StockQuoteService interface.
  • Next we add a mediation flow component, and wire the export to it. We then wire the mediation flow component to the imports.
  • Finally we generate implementation for the mediation flow component, and create the mediation flow in the mediation flow editor.

Adding function to the Stock Quote mediation service

We will change the mediation module and flow that we built earlier by adding logic to determine the customer's preferred currency. The code to execute the logic will be implemented using a Java component in the mediation module that will be called by the flow in the mediation flow component. There will be no change to the export, imports or their interfaces.

  • Open the mediation flow component, StockQuote_MediationFlow, and add a custom mediation primitive to the flow.
  • Define the interface and operation of the custom mediation primitive
  • Open the mediation module, StockQuote, in the assembly editor.
  • Select the mediation flow component in the assembly editor and synchronize references and merge implementation. A Java component with the required interface is created, along with a partner reference on the mediation flow component, and the components are wired.
  • Pick the implementation for the Java component.
Related concepts
Components and mediation modules
Quality of service: Qualifiers for mediation services
Using Java in a mediation module
Using Java in a mediation module
Related tasks
Creating a mediation module
Opening a mediation module assembly
Setting assembly editor preferences
Adding and wiring components
Editing the properties of elements in the mediation module assembly
Adding Qualities of Service (QoS) qualifiers
Processing events in a sequence
Working with implementations
Generating bindings for imports and exports
Invoking a module from another module
Interoperability with services from other vendors
Fixing errors in the assembly diagram
Best practice: Do not make changes to J2EE staging projects
Business services: Opening a module assembly
Business services: Generating bindings for imports and exports
Synchronizing the interfaces and references between components and implementations
Related reference
Assembly editor for mediation modules

Related information

Tutorial: Wire components using the assembly editor
Tutorial: Create a mediation flow
Samples: Mediation Flow editor
Tutorial: Wire components using the assembly editor

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