Note: This scenario is applicable for WebSphere® Enterprise Service Bus and IBM® Business Process Manager. Mediation modules can be deployed to WebSphere Enterprise Service Bus and IBM Business Process Manager. Modules can be deployed to IBM Business Process Manager.
In an integrated business application, business services interact with each other to provide a required function. A business service performs a repeatable function or task that contributes towards achieving a business goal. But the work of locating a service and connecting to it is not related to the business function. Separating the business function from the task of managing service connections provides flexibility to a solution.
Service interaction begins when a service requester sends a request to a service provider to perform a business function. This request is sent in the form of a message, which defines the function to be performed. The service provider performs the requested function and sends the result in a message to the service requester. Typically, messages need to be processed in order to allow the services to exchange data, and to implement other low level IT functions that are independent of the business functions and data. For example, routing, protocol conversion, transformation, retry of a failed invocation, and dynamic service invocation. This processing is known as mediation.
But there is not always a clear separation between business and mediation logic. In these cases, consider the amount of state, or data in variables that will need to be processed between service invocations. In general, if there is little or no state processing required, consider using a mediation flow component. If you need to store state between service invocations, or if you have data that will need to be stored in variables and processed, consider using a business process component. For example, if you are calling multiple services and recording the information that is returned from each, so that after invoking all the services, you want to do some further processing with the returned data, use a business process where you can easily assign the returned information to variables. In other words, when you have too much state you have crossed the line into business logic.
There is no one integration scenario, and there is no technically wrong answer. The guidelines that we discuss here are good practice to enable flexibility and reuse, and are presented for your consideration. As usual, you should carefully consider the benefits and drawbacks of implementing these patterns for your business integration application. Let's consider some situations.
Accessing an SCA component
A basic example of accessing a service is when an import calls another SCA component, without requiring any data transformation. Even in this situation, you could access the external service from a mediation module, rather than accessing it directly from a business module. This would allow flexibility in the future, for changing the service endpoint or qualities of service or governance (for example, adding logging) without impacting the business components that consume the service. This architectural pattern is known as "separation of concerns".
Before you decide to implement this pattern, weigh the benefits of the pattern against the potential effects of overhead introduced by another module. If your main requirement is flexibility, and you are going to make frequent changes to the services accessed, consider using a separate module as shown here. If performance is most important, and you are willing to update and redeploy the business logic, consider using a single module.
- Create a mediation module. For step-by-step instructions, see Creating mediation modules .
- In the mediation module, create an import with the appropriate binding for the external service that you want to access. For step-by-step instructions, see Creating imports. For more information on bindings, see Bindings
- Create an export, and give it the same interface as the import. For step-by-step instructions, see Creating exports.
- Generate an SCA binding for the export. For step-by-step instructions, see Generating SCA bindings
- In the mediation module's assembly, wire the export to the import. Save the mediation module.
- Create a module. For step-by-step instructions, see Creating a module for business services
- Add an export, and a component.
- In the Business integration view, drag the export that you created in the mediation module (in step 4) into the module assembly. An import with the same binding as the export will be created.
- Wire the export to the component, and the component to the import.
- Add the component's implementation. For information on implementation types, see Implementations
Later, you can add mediation logic such as logging or routing to the mediation module without affecting the business module.
Adding mediation
Sometimes it is not sufficient to simply invoke an external service. Sometimes you need to do processing first, by adding a mediation module as an intermediary between the service requester and provider.
- Setting protocol headers. For more information, see topic Protocol conversion in the WebSphere Enterprise Service Bus information center.
- Interface or parameter transformation by using a Business Object Map or XSL Transformation primitive.Transforming messages
- Selecting a particular service from a static list, by using a Message Filter primitive.Message filter
- Invoking multiple services to aggregate the results, by using the Fan out and Fan In primitives.Aggregating and broadcasting messages
- Dealing with service invocation failures by retrying the same service or invoking a different service, by using a Service Invoke primitive. Retrying a failed service invocation
- Dynamic routing by choosing which service to use at run time, rather than integration time, which 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 runtime environment. Dynamic routing is most powerful when used with a registry, which requires the Endpoint Lookup mediation primitive to be used.Selecting endpoints dynamically
Accessing Enterprise Information Systems
Services and artifacts on external systems can be imported into Integration Designer. A wizard discovers applications and data on an Enterprise Information Systems (EIS) and lets you generate services from the discovered applications and data. The generated artifacts are interfaces and business objects, which can be used by components in a module.
Using an intermediary mediation module between a module and a host system makes it more reusable. In the example below, a mediation flow is used to route to the correct host system, and to transform the data to the format required by the host system.
- Use the external service wizard to connect to the host system. Using the external service wizard to access external services follows a similar pattern regardless of the adapter you are using. For information on how to use the external service wizard, see Pattern of accessing external services with adapters
- Create a module. For step-by-step instructions, see Creating a module for business services
- Add an export, a component, and an import with SCA binding. For more information, see Calling services
- Add an interface to the export, and wire the export to the component.
- Add the component's implementation. In the implementation, set a property that indicates which host service will be accessed. For information on implementation types, see Implementations
- Create a mediation module with an export that has an SCA binding, and the same interface as the import of the module that you created in step 2.
- Wire the export to a mediation flow component.
- Create an import for each host system that you want to access, using the appropriate outbound adapter from the assembly editor palette.
- Wire the mediation flow component to the imports.
- Implement the mediation flow component. Use a Message Filter primitive to choose the import based on a property set in the business logic, and use an XSL transformation primitive for each adapter import. Message filter.
- In the module, select the mediation module's export as the service to be imported into the module. For step-by-step information, see Invoking a service from another module.
Accessing messaging systemsIn order for your service component architecture (SCA) module to communicate to an existing JMS, MQ or MQ JMS messaging client, you need to create interfaces, business objects and bindings for imports and exports. See Mapping a message to an SCA interface.
Mediation flows use messages, which provide access to context and header information in addition to business objects. If you want access to JMS header information or a custom JMS property, use a mediation flow. If you are integrating with an MQ system, and you want to access MQ header information, use a mediation flow.
For training on IBM Lombardi mail us at [email protected]