About Me

My photo
Charles L. Cambil, Bsc. Business Management, IBM I/T Architect, IBM Business Partner

Thursday, June 5, 2008

WID 6012.9 Mediation Flow How to

WID 6012.9 Mediation Flow How to

WID V6.0.1.2, Interim Fix 009

Contact us...

Table of Contents

How to add a Custom Mediation Primitive
How to add a Mediation Flow Component
How to create a Mediation Module
How to create custom mediation primitives
How to develop mediation flows using mediation primitives
How to implement a Java component in a Mediation Module
How to implement a Mediation Flow Component

Related links

Mediation flow

How to develop mediation flows using mediation primitives

How to create custom mediation primitives

How to create a Mediation Module

Related links

Mediation Module

Creating a mediation module

Create a mediation module

Right-click in the Business Integration view and select New > Mediation Module

Set up New Mediation Module Properties

Setup the following properties:

  1. Module Name
    Enter a mediation Module name (i.e NewMediationModule).
  2. Module Location
    Check Use default
  3. Target Runtime
    Select Websphere Process Server v6.0 or Websphere ESB Server v6.0
  4. Create mediation flow component
    Check it.
  5. Click Next.

Select the required Libraries

Select the required Libraries if any and click Finish.

New Mediation module is created

A new mediation module is created (i.e NewMediationModule). In addition, an empty mediation flow component (Mediation1) is also created (because you selected Create mediation flow component in the new mediation module properties setup above).

How to add a Mediation Flow Component

1-Open the Assembly Diagram

Double-click the assembly diagram icon in the Business Integration view to open the Assembly Diagram.

Notice that a mediation flow component (Mediation1) is automatically created. You can rename this component as required.

Note:

You can only have one mediation flow component in a mediation module. In other words, a mediation module can only have one mediation flow component.

2-Add additional Components/Node

In addition to one Mediation Flow component, you can also add the following components (Nodes) in the Assembly Diagram (see Figure at right).

Right-click inside the Assembly Diagram and select Add Node > ???.

  1. Java
    Implement custom mediation primitives invoked by the mediation flow component
  2. Import
    Identify service providers and their interfaces
  3. Export
    Expose the mediation module to service requesters
  4. Stand-alone References
    Enables a Non-SCA component (i.e JSP) to invoke a mediation service

How to implement a Mediation Flow Component

In the Assembly Diagram, right-click on the mediation flow component that you want to implement and select Generate Implementation.

Select the folder where the Mediation Flow implementation will be generated.

Select the default folder or New Folder and click OK.

The Mediation Flow Editor opens.

In the Operation connections section, the following are setup:

  1. Source interface
    One or more source interfaces that allow service requesters to access the mediation flow. These interfaces must match those of the exports that will be wired to the mediation flow component in the mediation module. Source interfaces are always created on the left side of the editor. A mediation flow must have a source interface.

  2. Target references
    Zero or more target references that allow a mediation flow component to access a service provider through an import in the mediation module. The reference specifies the interface that is used by the import to invoke the service. Target references are always created on the right side of the editor. Service references of custom mediation primitives are shown as unconnected target references.

In the Mediation flow section, the following are setup:

  1. Input node
    The first element on the left in the request flow view, derived from the source operation. This is the starting point for the request flow, and sends the message into the request flow. A flow can have only one input node.
  2. Input response node
    If a source operation is not wired to a target, the request flow typically ends with this node, which returns the processed message as a response to the source operation.

Connect the source operation (CCambil_DateTime_I) to the target operation (CCambil_DateTime_IPartner) if required.

After connecting the source operation to the target operation, notice that a Callout node (Invoke) is created.

Callout node An end point in the request flow, derived from the target operations. It sends the processed message to the target operation. There is one callout node for each target operation.

you are now ready to build the mediation flow itself.

How to implement a Java component in a Mediation Module

In the Assembly Diagram, right-click on the Java component that you want to implement and select Generate Implementation.

Select the package where the Java implementation will be generated.

You can select the default package or New Package.

Click OK.

If you selected New Package, enter Package name and click OK.

A new package is created (ccambil.java).

Select the package (ccambil.java) and click OK.

This is the generated Java source code.

Notice that you have to implement the public DataObject getTimeOfDay(DataObject input1) method.

package ccambil.java;

import commonj.sdo.DataObject;
import com.ibm.websphere.sca.ServiceManager;

public class CCambil_JavaComponent1Impl {
/**
* Default constructor.
*/
public CCambil_JavaComponent1Impl() {
super();
}

/**
* Return a reference to the component service instance for this implementation
* class. This method should be used when passing this service to a partner reference
* or if you want to invoke this component service asynchronously.
*
* @generated (com.ibm.wbit.java)
*/
private Object getMyService() {
return (Object) ServiceManager.INSTANCE.locateService("self");
}

/**
* Method generated to support implemention of operation "getTimeOfDay" defined for WSDL port type
* named "interface.CCambil_DateTime_I".
*
* The presence of commonj.sdo.DataObject as the return type and/or as a parameter
* type conveys that its a complex type. Please refer to the WSDL Definition for more information
* on the type of input, output and fault(s).
*/
public DataObject getTimeOfDay(DataObject input1) {
//TODO Needs to be implemented.
return null;
}

}

How to add a Custom Mediation Primitive

The completed etc.

  1. In the Business Integration view, expand the CustomMediation module.
  2. Open the Assembly Editor by double-clicking on the CustomMediation module assembly icon.
  3. The Assembly Diagram will be displayed.


In the module assembly diagram, right-click on the CustomMediationFlow component and choose Generate Implementation.

Click OK.

An initial mediation flow implementation is generated and the Mediation Flow Editor is automatically opened.

In the Operation Connections section, the source and the target operations are shown.

In the Mediation Flow section, the input and input response nodes are shown.

Input Node:

Request - getQuote : StockQuoteService

The input node is the starting point for the request flow. It sends the message from the source operation into the request flow.

Input Response Node:

Immediate Response

The input response node is an end point in the request and response flows. It returns the processed message as a response to the source operation.

In the Operation connections section, wire StockQuoteService interface's getQuote operation to StockQuoteServicePartner interface's getQuote operation.

After wiring the source to the target operation, a callout node appears.

Callout Node:

Invoke - getQuote : StockQuoteServicePartner

A callout node is an end point in the request flow. It sends the processed message to the target operation.

Add the PreferenceInformation business object to the correlation context of Request - getQuote : StockQuoteService. This will allow the property isPreferred to persist in the message flow.

  1. Click on Request - getQuote : StockQuoteService and switch to the Details tab in the Properties view.
  2. In the Correlation Context field, click Browse.

Select PreferenceInformation under matching data types, and double click.

{http://CustomMediation}

PreferenceInformation now appears in the Correlation Context field.

  1. Click on the Request tab.
  2. Select a Custom Mediation primitive from the palette.
  3. Drop it onto the request flow canvas, and rename it to Custom.

This mediation primitive allows the use of an existing SCA component operation within the mediation flow.

  1. Wire the output terminal of Request - getQuote : StockQuoteService to the input terminal of Custom.
  2. Wire the output terminal of Custom to the input terminal of Invoke - getQuote : StockQuoteServicePartner
  3. Click on the Define... button next to the Service operation field. The Define Custom Mediation wizard will be launched

In the Define Custom Mediation panel, leave the default selection to Create a new interface with implementation.

Click Next.

The Specify Message Types panel shows the input message type and output message type that will be used to create the new interface. Notice that the PreferenceInformation business object set in the correlation context is also shown in the Defined Contexts section.

  1. Change the Message Root field to /.
  2. Click Next

In the Create a new interface panel, change the Name field to NewCustomInterface.

Click Next.

In the Define Custom Mediation panel, leave the default selection to Generate a default Java implementation class and define it using the embedded visual snippet editor.

Click Finish.

Notice that a new reference NewCustomInterfacePartner has been created in the operation connections section

To add the Java code, do the following:

  1. Select Custom
  2. Select Properties/Implementation
  3. Paste the following code and save your changes:

// Get the symbol from the body of the message
String symbol = input1.getString("body/getQuote/symbol");

// If symbol is on the user's preferred list, set the isPreferred flag in the correlation context to 'true'
if (symbol.equals("ibm")) {

// Create the preferenceInformation business object and set the isPreferred flag to true
com.ibm.websphere.bo.BOFactory factory = (com.ibm.websphere.bo.BOFactory) new com.ibm.websphere.sca.ServiceManager().locateService("com/ibm/websphere/bo/BOFactory");
DataObject preferenceInformation = factory.create("
http://CustomMediation", "PreferenceInformation");
preferenceInformation.setBoolean("isPreferred", true);

// Set the business object in the correlation context
input1.setDataObject("context/correlation", preferenceInformation);

}
// Return the DataObject
return input1;

Synchronize interfaces and references and merge the java implementation in the assembly editor to create and wire the java component associated with the custom mediation.

  1. In the Assembly Editor, type Ctrl-S to save the changes. Right-click on the CustomMediationFlow component and select Synchronize Interfaces and References > from Implementation. Click OK in the dialog that asks whether you want to save all dirty editors and continue.

A Merge Implementation dialog is launched to show that the NewCustomInterfacePartner reference will be added using the interface NewCustomInterface. In addition, a corresponding Java™ component will be created.

Click OK.

Layout the contents by right-clicking inside the Assembly Diagram and selecting Layout Contents from the context menu.

No comments:

Visitor counter